git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Start deprecating "git-command" in favor of "git command"
@ 2007-06-30 18:49 Linus Torvalds
  2007-06-30 19:17 ` Junio C Hamano
  2007-06-30 20:34 ` walt
  0 siblings, 2 replies; 23+ messages in thread
From: Linus Torvalds @ 2007-06-30 18:49 UTC (permalink / raw)
  To: Junio C Hamano, Git Mailing List


I realize that a lot of people use the "git-xyzzy" format, and we have 
various historical reasons for it, but I also think that most people have 
long since started thinking of the git command as a single command with 
various subcommands, and we've long had the documentation talk about it 
that way.

Slowly migrating away from the git-xyzzy format would allow us to 
eventually no longer install hundreds of binaries (even if most of them 
are symlinks or hardlinks) in users $PATH, and the _original_ reasons for 
it (implementation issues and bash completion) are really long long gone.

Using "git xyzzy" also has some fundamental advantages, like the ability 
to specify things like paging ("git -p xyzzy") and making the whole notion 
of aliases act like other git commands (which they already do, but they do 
*not* have a "git-xyzzy" form!)

Anyway, while actually removing the "git-xyzzy" things is not practical 
right now, we can certainly start slowly to deprecate it internally inside 
git itself - in the shell scripts we use, and the test vectors.

This patch adds a "remove-dashes" makefile target, which does that. It 
isn't particularly efficient or smart, but it *does* successfully rewrite 
a lot of our shell scripts to use the "git xyzzy" form for all built-in 
commands.

(For non-builtins, the "git xyzzy" format implies an extra execve(), so 
this script leaves those alone).

So apply this patch, and then run

	make remove-dashes
	make test
	git commit -a

to generate a much larger patch that actually starts this transformation.

(The only half-way subtle thing about this is that it also fixes up 
git-filter-branch.sh for the new world order by adding quoting around 
the use of "git-commit-tree" as an argument. It doesn't need it in that 
format, but when changed into "git commit-tree" it is no longer a single 
word, and the quoting maintains the old behaviour).

NOTE! This does not yet mean that you can actually stop installing the 
"git-xyzzy" binaries for the builtins. There are some remaining places 
that want to use the old form, this just removes the most obvious ones 
that can easily be done automatically.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---

Comments? I think this is worth doing, but the patch that this scripting 
generates is actually fairly large, even if this patch itself is smallish.

Junio, up to you.

 Makefile             |    3 ++-
 fixup-builtins       |   16 ++++++++++++++++
 git-filter-branch.sh |    2 +-
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index a98e27a..1620ef8 100644
--- a/Makefile
+++ b/Makefile
@@ -987,7 +987,8 @@ check-sha1:: test-sha1$X
 check: common-cmds.h
 	for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done
 
-
+remove-dashes:
+	./fixup-builtins $(BUILT_INS)
 
 ### Installation rules
 
diff --git a/fixup-builtins b/fixup-builtins
new file mode 100755
index 0000000..d7fae43
--- /dev/null
+++ b/fixup-builtins
@@ -0,0 +1,16 @@
+#!/bin/sh
+while [ "$1" ]
+do
+	old="$1"
+	new=$(echo "$1" | sed 's/git-/git /')
+	echo "Converting '$old' to '$new'"
+	git ls-files '*.sh' | while read file
+	do
+		sed "s/$old/$new/g" < $file > $file.new
+		chmod --reference=$file $file.new
+		mv $file.new $file
+	done
+	shift
+done
+git update-index --refresh >& /dev/null
+exit 0
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 8fa5ce6..0f54271 100644
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -383,7 +383,7 @@ while read commit parents; do
 
 	sed -e '1,/^$/d' <../commit | \
 		eval "$filter_msg" | \
-		sh -c "$filter_commit" git-commit-tree $(git-write-tree) $parentstr | \
+		sh -c "$filter_commit" "git-commit-tree" $(git-write-tree) $parentstr | \
 		tee ../map/$commit
 done <../revs
 

^ permalink raw reply related	[flat|nested] 23+ messages in thread
* Re: Start deprecating "git-command" in favor of "git command"
@ 2007-07-01  0:45 linux
  2007-07-01  1:48 ` eschvoca
  0 siblings, 1 reply; 23+ messages in thread
From: linux @ 2007-07-01  0:45 UTC (permalink / raw)
  To: git

H'm... I use the git-foo forms a lot so I can do easy history substitution.
In particular, "!git-grep" (actually, "!git-g") gets used a fair bit.

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2007-07-03  3:50 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-30 18:49 Start deprecating "git-command" in favor of "git command" Linus Torvalds
2007-06-30 19:17 ` Junio C Hamano
2007-06-30 19:43   ` Yann Dirson
2007-07-01  2:25     ` Junio C Hamano
2007-07-01  3:01       ` Linus Torvalds
2007-07-01  3:32         ` Junio C Hamano
2007-07-01 12:12           ` Johannes Schindelin
2007-07-01 18:16             ` Junio C Hamano
2007-07-03  2:56           ` Nicolas Pitre
2007-07-03  3:50             ` Junio C Hamano
2007-06-30 19:43   ` Linus Torvalds
2007-06-30 20:08     ` Junio C Hamano
2007-06-30 20:22   ` Junio C Hamano
2007-07-01  8:22   ` Jeff King
2007-07-01 13:48     ` Johannes Schindelin
2007-07-01 21:11       ` Josh Triplett
2007-06-30 20:34 ` walt
2007-06-30 21:37   ` Johannes Schindelin
2007-06-30 22:40     ` walt
2007-07-01 13:47     ` Yann Dirson
  -- strict thread matches above, loose matches on Subject: below --
2007-07-01  0:45 linux
2007-07-01  1:48 ` eschvoca
2007-07-01  3:00   ` Theodore Tso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).