From 1c606c2be5d21dc570caba510110f63d15d09565 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 58ef570294..32ba8de3d2 100644 --- a/git.c +++ b/git.c @@ -575,6 +575,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 ea8a143ff2ebe7167d3b71a0aaac84cc40d22ec9 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 7f2425799d025318df575648fd059f17fb07a6fb 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 4c3b9035ac3a854fbf811ac292017e3ba2ff2214 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 e7b85932d6..b25ae50b2e 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")" From 56cfa6b1c13fb2b68154118831ff8f7d8065c9c8 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 4bc75d0438933e9612d498079ef11fd1adbac658 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 ced106b538dab7fb7a2068a7da0f3fd4dfab86e8 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 c0d0e9a4c6..32c8803777 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -863,7 +863,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 ) @@ -897,11 +897,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")