From edacdff27f29e6aa251ecff10f9829253b71e28a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 28 Nov 2016 18:17:49 +0100 Subject: [PATCH 1/7] git: avoid calling aliased builtins via their dashed form This is one of the few places where Git violates its own deprecation of the dashed form. It is not necessary, either. Signed-off-by: Johannes Schindelin --- git.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/git.c b/git.c index 489aab4d83..3a7fa8bb2f 100644 --- a/git.c +++ b/git.c @@ -588,6 +588,33 @@ static int run_argv(int *argcp, const char ***argv) */ if (!done_alias) handle_builtin(*argcp, *argv); + else if (get_builtin(**argv)) { + struct argv_array args = ARGV_ARRAY_INIT; + int i; + + if (get_super_prefix()) + die("%s doesn't support --super-prefix", **argv); + + if (use_pager == -1) + use_pager = check_pager_config(**argv); + commit_pager_choice(); + + argv_array_push(&args, "git"); + for (i = 0; i < *argcp; i++) + argv_array_push(&args, (*argv)[i]); + + trace_argv_printf(args.argv, "trace: exec:"); + + /* + * if we fail because the command is not found, it is + * OK to return. Otherwise, we just pass along the status code. + */ + i = run_command_v_opt(args.argv, RUN_SILENT_EXEC_FAILURE | + RUN_CLEAN_ON_EXIT); + if (i >= 0 || errno != ENOENT) + exit(i); + die("could not execute builtin %s", **argv); + } /* .. then try the external ones */ execv_dashed_external(*argv); From 3fa87bd199759f3200046e7290e90094b622d67a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Nov 2016 11:40:55 +0100 Subject: [PATCH 2/7] merge-resolve: avoid dashed call We started deprecating the dashed form a long time ago, advertising the fact that dashed invocations of Git commands are deprecated for several major versions. Yet we still used them ourselves. With ashes on our heads, we now start to finally get rid of those calls. Signed-off-by: Johannes Schindelin --- git-merge-resolve.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-merge-resolve.sh b/git-merge-resolve.sh index c9da747fcf..343fe7bccd 100755 --- a/git-merge-resolve.sh +++ b/git-merge-resolve.sh @@ -45,7 +45,7 @@ then exit 0 else echo "Simple merge failed, trying Automatic merge." - if git-merge-index -o git-merge-one-file -a + if git merge-index -o git-merge-one-file -a then exit 0 else From 28f372dac3d168af9eec7c47e7aa4253053453d1 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Nov 2016 23:34:18 +0100 Subject: [PATCH 3/7] rebase--merge: avoid dashed invocation We deprecated the dashed invocations ages ago. Might just as well hold ourselves to that. Signed-off-by: Johannes Schindelin --- git-rebase--merge.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh index 06a4723d4d..9bc88b7054 100644 --- a/git-rebase--merge.sh +++ b/git-rebase--merge.sh @@ -69,7 +69,7 @@ call_merge () { test -z "$strategy" && strategy=recursive # If cmt doesn't have a parent, don't include it as a base base=$(git rev-parse --verify --quiet $cmt^) - eval 'git-merge-$strategy' $strategy_opts $base ' -- "$hd" "$cmt"' + eval 'git merge-$strategy' $strategy_opts $base ' -- "$hd" "$cmt"' rv=$? case "$rv" in 0) From 37896fe03fe1568300d01da1a702557ea8716272 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Nov 2016 23:34:18 +0100 Subject: [PATCH 4/7] stash: avoid dashed invocation The invocation of dashed Git commands was rightfully deprecated a long time ago. We failed to heed that deprecation ourselves, but it is never too late... Signed-off-by: Johannes Schindelin --- git-stash.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-stash.sh b/git-stash.sh index 9b6c2da7b4..9aa09c3a33 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -573,7 +573,7 @@ apply_stash () { if test -n "$u_tree" then - GIT_INDEX_FILE="$TMPindex" git-read-tree "$u_tree" && + GIT_INDEX_FILE="$TMPindex" git read-tree "$u_tree" && GIT_INDEX_FILE="$TMPindex" git checkout-index --all && rm -f "$TMPindex" || die "$(gettext "Could not restore untracked files from stash entry")" From c51e86bc66527ae315c6c791b280d8ea48e155eb Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Nov 2016 23:34:18 +0100 Subject: [PATCH 5/7] merge-octopus: avoid dashed invocation A long time ago, in turn a long time after introducing builtins and moving Git's scripts to libexec/git-core/, we deprecated the invocation of dashed commands. The merge-octopus script is a holdover from the time before that, as it still tries to invoke a builtin by its dashed form. Let's just not. Signed-off-by: Johannes Schindelin --- git-merge-octopus.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-merge-octopus.sh b/git-merge-octopus.sh index bcf0d92ec2..6c390d6c22 100755 --- a/git-merge-octopus.sh +++ b/git-merge-octopus.sh @@ -100,7 +100,7 @@ do if test $? -ne 0 then gettextln "Simple merge did not work, trying automatic merge." - git-merge-index -o git-merge-one-file -a || + git merge-index -o git-merge-one-file -a || OCTOPUS_FAILURE=1 next=$(git write-tree 2>/dev/null) fi From 6b756726da166e9a2fdfde3442ce82fd4432cf87 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Nov 2016 23:34:18 +0100 Subject: [PATCH 6/7] merge-one-file: avoid dashed invocation The original idea of deprecating invocations of Git subcommands via their dashed form was to be able to ship without having to hard-link each and every builtin to its dashed form. We need to follow this plan ourselves, by patching our very own scripts accordingly. Signed-off-by: Johannes Schindelin --- git-merge-one-file.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh index 424b034e34..9879c59395 100755 --- a/git-merge-one-file.sh +++ b/git-merge-one-file.sh @@ -115,16 +115,16 @@ case "${1:-.}${2:-.}${3:-.}" in ;; esac - src1=$(git-unpack-file $2) - src2=$(git-unpack-file $3) + src1=$(git unpack-file $2) + src2=$(git unpack-file $3) case "$1" in '') echo "Added $4 in both, but differently." - orig=$(git-unpack-file e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) + orig=$(git unpack-file e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) ;; *) echo "Auto-merging $4" - orig=$(git-unpack-file $1) + orig=$(git unpack-file $1) ;; esac From 1f93eff48af6082609bdcdd764c855cc1975f1eb Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Nov 2016 23:34:18 +0100 Subject: [PATCH 7/7] submodule: avoid dashed invocation In the years-old effort to clean up the PATH a bit, we deprecated dashed invocations. But we did not hold ourselves to that. Until now. Signed-off-by: Johannes Schindelin --- git-submodule.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index e131760eec..ffa2d66481 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -864,7 +864,7 @@ cmd_summary() { test $status != A && test $ignore_config = all && continue fi # Also show added or modified modules which are checked out - GIT_DIR="$sm_path/.git" git-rev-parse --git-dir >/dev/null 2>&1 && + GIT_DIR="$sm_path/.git" git rev-parse --git-dir >/dev/null 2>&1 && printf '%s\n' "$sm_path" done ) @@ -898,11 +898,11 @@ cmd_summary() { missing_dst= test $mod_src = 160000 && - ! GIT_DIR="$name/.git" git-rev-parse -q --verify $sha1_src^0 >/dev/null && + ! GIT_DIR="$name/.git" git rev-parse -q --verify $sha1_src^0 >/dev/null && missing_src=t test $mod_dst = 160000 && - ! GIT_DIR="$name/.git" git-rev-parse -q --verify $sha1_dst^0 >/dev/null && + ! GIT_DIR="$name/.git" git rev-parse -q --verify $sha1_dst^0 >/dev/null && missing_dst=t display_name=$(git submodule--helper relative-path "$name" "$wt_prefix")