From d28c8af623b0d15740c2af0106d8e2bf54a3ac52 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Dec 2005 12:50:40 -0800 Subject: [PATCH 01/39] diffcore-break.c: check diff_delta() return value. This bug caused Darrin Thompson to notice that our deltifier was half broken and punting on an empty blob. Signed-off-by: Junio C Hamano --- diffcore-break.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/diffcore-break.c b/diffcore-break.c index 06f9a7f0ee..e6a468e6b0 100644 --- a/diffcore-break.c +++ b/diffcore-break.c @@ -66,6 +66,8 @@ static int should_break(struct diff_filespec *src, delta = diff_delta(src->data, src->size, dst->data, dst->size, &delta_size, 0); + if (!delta) + return 0; /* error but caught downstream */ /* Estimate the edit size by interpreting delta. */ if (count_delta(delta, delta_size, From e726715a52e25d8035c89d4ea09398599610737e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Dec 2005 12:28:34 -0800 Subject: [PATCH 02/39] Add deltifier test. This test kicks in only if you built test-delta executable, and makes sure that the basic delta routine is working properly even on empty files. This commit is to make sure we have a test to catch the breakage. The delitifier code is still broken, which will be fixed with the next commit. Signed-off-by: Junio C Hamano --- t/t0001-delta.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ test-delta.c | 11 +++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100755 t/t0001-delta.sh diff --git a/t/t0001-delta.sh b/t/t0001-delta.sh new file mode 100755 index 0000000000..2dd88e503d --- /dev/null +++ b/t/t0001-delta.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +test_description='Deltification regression test' + +../test-delta 2>/dev/null +test $? == 127 && { + echo "* Skipping test-delta regression test." + exit 0 +} + +. ./test-lib.sh + +>empty +echo small >small +echo smallish >smallish +cat ../../COPYING >large +sed -e 's/GNU/G.N.U/g' large >largish + +test_expect_success 'No regression in deltify code' \ +' +fail=0 +for src in empty small smallish large largish +do + for dst in empty small smallish large largish + do + if test-delta -d $src $dst delta-$src-$dst && + test-delta -p $src delta-$src-$dst out-$src-$dst && + cmp $dst out-$src-$dst + then + echo "* OK ($src->$dst deitify and apply)" + else + echo "* FAIL ($src->$dst deitify and apply)" + fail=1 + fi + done +done +case "$fail" in +0) (exit 0) ;; +*) (exit $fail) ;; +esac +' + +test_done diff --git a/test-delta.c b/test-delta.c index 1be8ee0c72..cc05794ec0 100644 --- a/test-delta.c +++ b/test-delta.c @@ -38,7 +38,10 @@ int main(int argc, char *argv[]) return 1; } from_size = st.st_size; - from_buf = mmap(NULL, from_size, PROT_READ, MAP_PRIVATE, fd, 0); + if (from_size) + from_buf = mmap(NULL, from_size, PROT_READ, MAP_PRIVATE, fd, 0); + else + from_buf = ""; if (from_buf == MAP_FAILED) { perror(argv[2]); close(fd); @@ -52,7 +55,11 @@ int main(int argc, char *argv[]) return 1; } data_size = st.st_size; - data_buf = mmap(NULL, data_size, PROT_READ, MAP_PRIVATE, fd, 0); + + if (data_size) + data_buf = mmap(NULL, data_size, PROT_READ, MAP_PRIVATE, fd, 0); + else + data_buf = ""; if (data_buf == MAP_FAILED) { perror(argv[3]); close(fd); From 962537a3eb03a118cf27d9d0da365a3216ed1caa Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Dec 2005 12:01:52 -0800 Subject: [PATCH 03/39] diff-delta.c: allow delta with empty blob. Delta computation with an empty blob used to punt and returned NULL. This commit allows creation with empty blob; all combination of empty->empty, empty->something, and something->empty are allowed. Signed-off-by: Junio C Hamano --- delta.h | 4 ++-- diff-delta.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/delta.h b/delta.h index 31d1820f80..c6a476353f 100644 --- a/delta.h +++ b/delta.h @@ -9,8 +9,8 @@ extern void *patch_delta(void *src_buf, unsigned long src_size, void *delta_buf, unsigned long delta_size, unsigned long *dst_size); -/* the smallest possible delta size is 4 bytes */ -#define DELTA_SIZE_MIN 4 +/* the smallest possible delta size is 2 bytes (empty to empty) */ +#define DELTA_SIZE_MIN 2 /* * This must be called twice on the delta data buffer, first to get the diff --git a/diff-delta.c b/diff-delta.c index b2ae7b5e6c..cf5013896f 100644 --- a/diff-delta.c +++ b/diff-delta.c @@ -213,7 +213,7 @@ void *diff_delta(void *from_buf, unsigned long from_size, bdrecord_t *brec; bdfile_t bdf; - if (!from_size || !to_size || delta_prepare(from_buf, from_size, &bdf)) + if (delta_prepare(from_buf, from_size, &bdf)) return NULL; outpos = 0; From 44db136cad84c003506e231a38935ca6acba4d7d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Dec 2005 16:20:21 -0800 Subject: [PATCH 04/39] Everyday: some examples. Signed-off-by: Junio C Hamano --- Documentation/everyday.txt | 72 +++++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 4 deletions(-) diff --git a/Documentation/everyday.txt b/Documentation/everyday.txt index 5775cd28ac..ded4d512d8 100644 --- a/Documentation/everyday.txt +++ b/Documentation/everyday.txt @@ -59,9 +59,6 @@ following commands. * gitlink:git-show-branch[1] to see where you are. - * gitlink:git-diff[1] and gitlink:git-status[1] to see what - you are in the middle of doing. - * gitlink:git-log[1] to see what happened. * gitlink:git-whatchanged[1] to find out where things have @@ -70,7 +67,11 @@ following commands. * gitlink:git-checkout[1] and gitlink:git-branch[1] to switch branches. - * gitlink:git-update-index[1] to manage the index file. + * gitlink:git-add[1] and gitlink:git-update-index[1] to manage + the index file. + + * gitlink:git-diff[1] and gitlink:git-status[1] to see what + you are in the middle of doing. * gitlink:git-commit[1] to advance the current branch. @@ -83,6 +84,37 @@ following commands. * gitlink:git-rebase[1] to maintain topic branches. +Examples +~~~~~~~~ + +* Extract a tarball and create a working tree and a new repository to keep track of it. +------------ +$ tar zxf frotz.tar.gz +$ cd frotz +$ git-init-db +$ git add . +$ git commit -m 'import of frotz source tree.' +------------ + +* Create a topic branch and develop +------------ +$ git checkout -b private +$ edit/compile/test +$ git diff <1> +$ git checkout -- foo.c <2> +$ edit/compile/test +$ git commit -a -s <3> +$ git checkout master <4> +$ git pull . private <5> + +<1> to see what changes you are committing. +<2> revert your botched changes in selected path "foo.c". +<3> commit everything as you have tested. +<4> switch to the master branch. +<5> merge a topic branch into your master branch +------------ + + Individual Developer (Participant)[[Individual Developer (Participant)]] ------------------------------------------------------------------------ @@ -100,6 +132,38 @@ addition to the ones needed by a standalone developer. you adopt Linux kernel-style public forum workflow. +Examples +~~~~~~~~ + +* Clone the upstream and work on it. Feed changes to upstream. +------------ +$ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6 +$ cd my2.6 +$ edit/compile/test; git commit -a -s <1> +$ git format-patch master <2> +$ git pull <3> +$ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <4> + +<1> repeat as needed. +<2> extract patches from your branch for e-mail submission. +<3> "pull" fetches from "origin" by default and merges. +<4> fetch from a specific branch from a specific repository and and merge. +------------ + +* Branch off of a specific tag. +------------ +$ git checkout -b private2.6.14 v2.6.14 <1> +$ edit/compile/test; git commit -a +$ git checkout master +$ git format-patch -k -m --stdout v2.6.14..private2.6.14 | + git am -3 -k <2> +<1> create a private branch based on a well known (but somewhat behind) +tag. +<2> forward port all changes in private2.6.14 branch to master +branch without formal "merging". +------------ + + Integrator[[Integrator]] ------------------------ From c7a45bd20e4ec141fdc15f36d261a45d51d95693 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Dec 2005 16:42:38 -0800 Subject: [PATCH 05/39] Revert "diff-delta.c: allow delta with empty blob." This reverts 962537a3eb03a118cf27d9d0da365a3216ed1caa commit to play safe. --- delta.h | 4 ++-- diff-delta.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/delta.h b/delta.h index c6a476353f..31d1820f80 100644 --- a/delta.h +++ b/delta.h @@ -9,8 +9,8 @@ extern void *patch_delta(void *src_buf, unsigned long src_size, void *delta_buf, unsigned long delta_size, unsigned long *dst_size); -/* the smallest possible delta size is 2 bytes (empty to empty) */ -#define DELTA_SIZE_MIN 2 +/* the smallest possible delta size is 4 bytes */ +#define DELTA_SIZE_MIN 4 /* * This must be called twice on the delta data buffer, first to get the diff --git a/diff-delta.c b/diff-delta.c index cf5013896f..b2ae7b5e6c 100644 --- a/diff-delta.c +++ b/diff-delta.c @@ -213,7 +213,7 @@ void *diff_delta(void *from_buf, unsigned long from_size, bdrecord_t *brec; bdfile_t bdf; - if (delta_prepare(from_buf, from_size, &bdf)) + if (!from_size || !to_size || delta_prepare(from_buf, from_size, &bdf)) return NULL; outpos = 0; From 86c9523305f75818d4dce485a18f6b4ccae78233 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Dec 2005 16:43:15 -0800 Subject: [PATCH 06/39] Revert "Add deltifier test." This reverts e726715a52e25d8035c89d4ea09398599610737e commit, because reverting diff-delta emptiness change would break this test. --- t/t0001-delta.sh | 43 ------------------------------------------- test-delta.c | 11 ++--------- 2 files changed, 2 insertions(+), 52 deletions(-) delete mode 100755 t/t0001-delta.sh diff --git a/t/t0001-delta.sh b/t/t0001-delta.sh deleted file mode 100755 index 2dd88e503d..0000000000 --- a/t/t0001-delta.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -test_description='Deltification regression test' - -../test-delta 2>/dev/null -test $? == 127 && { - echo "* Skipping test-delta regression test." - exit 0 -} - -. ./test-lib.sh - ->empty -echo small >small -echo smallish >smallish -cat ../../COPYING >large -sed -e 's/GNU/G.N.U/g' large >largish - -test_expect_success 'No regression in deltify code' \ -' -fail=0 -for src in empty small smallish large largish -do - for dst in empty small smallish large largish - do - if test-delta -d $src $dst delta-$src-$dst && - test-delta -p $src delta-$src-$dst out-$src-$dst && - cmp $dst out-$src-$dst - then - echo "* OK ($src->$dst deitify and apply)" - else - echo "* FAIL ($src->$dst deitify and apply)" - fail=1 - fi - done -done -case "$fail" in -0) (exit 0) ;; -*) (exit $fail) ;; -esac -' - -test_done diff --git a/test-delta.c b/test-delta.c index cc05794ec0..1be8ee0c72 100644 --- a/test-delta.c +++ b/test-delta.c @@ -38,10 +38,7 @@ int main(int argc, char *argv[]) return 1; } from_size = st.st_size; - if (from_size) - from_buf = mmap(NULL, from_size, PROT_READ, MAP_PRIVATE, fd, 0); - else - from_buf = ""; + from_buf = mmap(NULL, from_size, PROT_READ, MAP_PRIVATE, fd, 0); if (from_buf == MAP_FAILED) { perror(argv[2]); close(fd); @@ -55,11 +52,7 @@ int main(int argc, char *argv[]) return 1; } data_size = st.st_size; - - if (data_size) - data_buf = mmap(NULL, data_size, PROT_READ, MAP_PRIVATE, fd, 0); - else - data_buf = ""; + data_buf = mmap(NULL, data_size, PROT_READ, MAP_PRIVATE, fd, 0); if (data_buf == MAP_FAILED) { perror(argv[3]); close(fd); From 0532a5e46b88cd70c952a2bf5dc63681be32a2d9 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Dec 2005 17:15:55 -0800 Subject: [PATCH 07/39] diffcore-break: do not break too small filepair. Somehow we checked only one side and not the other. By checking the filesize upfront, we can bypass generating delta unnecessarily. Signed-off-by: Junio C Hamano --- diffcore-break.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/diffcore-break.c b/diffcore-break.c index e6a468e6b0..c57513a4fa 100644 --- a/diffcore-break.c +++ b/diffcore-break.c @@ -62,6 +62,8 @@ static int should_break(struct diff_filespec *src, return 0; /* error but caught downstream */ base_size = ((src->size < dst->size) ? src->size : dst->size); + if (base_size < MINIMUM_BREAK_SIZE) + return 0; /* we do not break too small filepair */ delta = diff_delta(src->data, src->size, dst->data, dst->size, @@ -170,8 +172,7 @@ void diffcore_break(int break_score) !S_ISDIR(p->one->mode) && !S_ISDIR(p->two->mode) && !strcmp(p->one->path, p->two->path)) { if (should_break(p->one, p->two, - break_score, &score) && - MINIMUM_BREAK_SIZE <= p->one->size) { + break_score, &score)) { /* Split this into delete and create */ struct diff_filespec *null_one, *null_two; struct diff_filepair *dp; From 180c4746479892a9e58918b0d45f89911cb48716 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Dec 2005 18:29:53 -0800 Subject: [PATCH 08/39] Everyday: a bit more example. Signed-off-by: Junio C Hamano --- Documentation/everyday.txt | 110 +++++++++++++++++++++++++++++++------ 1 file changed, 93 insertions(+), 17 deletions(-) diff --git a/Documentation/everyday.txt b/Documentation/everyday.txt index ded4d512d8..88df3ffc28 100644 --- a/Documentation/everyday.txt +++ b/Documentation/everyday.txt @@ -83,6 +83,7 @@ following commands. * gitlink:git-rebase[1] to maintain topic branches. + * gitlink:git-tag[1] to mark known point. Examples ~~~~~~~~ @@ -92,26 +93,48 @@ Examples $ tar zxf frotz.tar.gz $ cd frotz $ git-init-db -$ git add . +$ git add . <1> $ git commit -m 'import of frotz source tree.' +$ git tag v2.43 <2> + +<1> add everything under the current directory. +<2> make a lightweight, unannotated tag. ------------ * Create a topic branch and develop ------------ -$ git checkout -b private +$ git checkout -b alsa-audio <1> +$ edit/compile/test +$ git checkout -- curses/ux_audio_oss.c <2> +$ git add curses/ux_audio_alsa.c <3> +$ edit/compile/test +$ git diff <4> +$ git commit -a -s <5> $ edit/compile/test -$ git diff <1> -$ git checkout -- foo.c <2> +$ git reset --soft HEAD^ <6> $ edit/compile/test -$ git commit -a -s <3> -$ git checkout master <4> -$ git pull . private <5> - -<1> to see what changes you are committing. -<2> revert your botched changes in selected path "foo.c". -<3> commit everything as you have tested. -<4> switch to the master branch. -<5> merge a topic branch into your master branch +$ git diff ORIG_HEAD <7> +$ git commit -a -c ORIG_HEAD <8> +$ git checkout master <9> +$ git pull . alsa-audio <10> +$ git log --since='3 days ago' <11> +$ git log v2.43.. curses/ <12> + +<1> create a new topic branch. +<2> revert your botched changes in "curses/ux_audio_oss.c". +<3> you need to tell git if you added a new file; removal and +modification will be caught if you do "commit -a" later. +<4> to see what changes you are committing. +<5> commit everything as you have tested, with your sign-off. +<6> take the last commit back, keeping what is in the working tree. +<7> look at the changes since the premature commit we took back. +<8> redo the commit undone in the previous step, using the message +you originally wrote. +<9> switch to the master branch. +<10> merge a topic branch into your master branch +<11> or --since='aug 1', --max-count=10 +<12> view only the changes that touch what's in curses/ +directory, since v2.43 tag. ------------ @@ -142,12 +165,19 @@ $ cd my2.6 $ edit/compile/test; git commit -a -s <1> $ git format-patch master <2> $ git pull <3> -$ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <4> +$ git whatchanged -p ORIG_HEAD.. arch/i386 include/asm-i386 <4> +$ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <5> +$ git reset --hard ORIG_HEAD <6> +$ git prune <7> <1> repeat as needed. <2> extract patches from your branch for e-mail submission. <3> "pull" fetches from "origin" by default and merges. -<4> fetch from a specific branch from a specific repository and and merge. +<4> look at the changes since last time we checked, only in the +area we are interested in. +<5> fetch from a specific branch from a specific repository and and merge. +<6> revert the pull. +<7> garbage collect leftover objects from reverted pull. ------------ * Branch off of a specific tag. @@ -157,10 +187,11 @@ $ edit/compile/test; git commit -a $ git checkout master $ git format-patch -k -m --stdout v2.6.14..private2.6.14 | git am -3 -k <2> + <1> create a private branch based on a well known (but somewhat behind) tag. -<2> forward port all changes in private2.6.14 branch to master -branch without formal "merging". +<2> forward port all changes in private2.6.14 branch to master branch +without a formal "merging". ------------ @@ -185,6 +216,51 @@ commands in addition to the ones needed by participants. * gitlink:git-push[1] to publish the bleeding edge. +Examples +~~~~~~~~ + +* My typical GIT day. +------------ +$ git status <1> +$ git show-branch <2> +$ mailx <3> +& s 2 3 4 5 ./+to-apply +& s 7 8 ./+hold-linus +& q +$ git checkout master +$ git am -3 -i -s -u ./+to-apply <4> +$ compile/test +$ git checkout -b hold/linus && git am -3 -i -s -u ./+hold-linus <5> +$ git checkout pu && git reset --hard master <6> +$ git pull . topic/one topic/two && git pull . hold/linus <7> +$ git fetch ko master:refs/tags/ko-master && + git show-branch master ko-master <8> +$ git push ko <9> +$ git checkout maint +$ git cherry-pick master~4 <10> +$ compile/test +$ git tag -s -m 'GIT 0.99.9x' v0.99.9x <11> +$ git push ko v0.99.9x <12> + +<1> see what I was in the middle of doing, if any. +<2> see what topic branches I have and think about how ready +they are. +<3> read mails, save ones that are applicable, and save others +that are not quite ready. +<4> apply them, interactively, with my sign-offs. +<5> create topic branch as needed and apply, again with my +sign-offs. +<6> restart "pu" every time from the master. +<7> and bundle topic branches still cooking. +<8> make sure I did not accidentally rewound master beyond what I +already pushed out. +<9> push out the bleeding edge. +<10> backport a critical fix. +<11> create a signed tag. +<12> push the tag out. +------------ + + Repository Administration[[Repository Administration]] ------------------------------------------------------ From 1e2ccd3abc8f5d96244806f753568493c3e77d4c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Dec 2005 23:24:06 -0800 Subject: [PATCH 09/39] Documentation: more examples. Signed-off-by: Junio C Hamano --- Documentation/everyday.txt | 99 +++++++++++++++++++++++++++------- Documentation/git-am.txt | 2 +- Documentation/git-branch.txt | 26 +++++++++ Documentation/git-checkout.txt | 10 ++-- Documentation/git-clone.txt | 21 ++++++++ Documentation/git-init-db.txt | 7 ++- Documentation/git-reset.txt | 70 ++++++++++++++++++++++++ 7 files changed, 209 insertions(+), 26 deletions(-) diff --git a/Documentation/everyday.txt b/Documentation/everyday.txt index 88df3ffc28..88bd88963a 100644 --- a/Documentation/everyday.txt +++ b/Documentation/everyday.txt @@ -50,6 +50,35 @@ Everybody uses these commands to feed and care git repositories. * gitlink:git-repack[1] to pack loose objects for efficiency. +Examples +~~~~~~~~ + +Check health and remove cruft:: ++ +------------ +$ git fsck-objects <1> +$ git prune +$ git count-objects <2> +$ git repack <3> +$ git prune <4> + +<1> running without "--full" is usually cheap and assures the +repository health reasonably well. +<2> check how many loose objects there are and how much +diskspace is wasted by not repacking. +<3> without "-a" repacks incrementally. repacking every 4-5MB +of loose objects accumulation may be a good rule of thumb. +<4> after repack, prune removes the duplicate loose objects. +------------ + +Repack a small project into single pack:: ++ +------------ +$ git repack -a -d <1> +$ git prune +------------ + + Individual Developer (Standalone)[[Individual Developer (Standalone)]] ---------------------------------------------------------------------- @@ -88,7 +117,8 @@ following commands. Examples ~~~~~~~~ -* Extract a tarball and create a working tree and a new repository to keep track of it. +Extract a tarball and create a working tree and a new repository to keep track of it:: ++ ------------ $ tar zxf frotz.tar.gz $ cd frotz @@ -101,7 +131,8 @@ $ git tag v2.43 <2> <2> make a lightweight, unannotated tag. ------------ -* Create a topic branch and develop +Create a topic branch and develop:: ++ ------------ $ git checkout -b alsa-audio <1> $ edit/compile/test @@ -158,12 +189,13 @@ addition to the ones needed by a standalone developer. Examples ~~~~~~~~ -* Clone the upstream and work on it. Feed changes to upstream. +Clone the upstream and work on it. Feed changes to upstream:: ++ ------------ $ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6 $ cd my2.6 $ edit/compile/test; git commit -a -s <1> -$ git format-patch master <2> +$ git format-patch origin <2> $ git pull <3> $ git whatchanged -p ORIG_HEAD.. arch/i386 include/asm-i386 <4> $ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <5> @@ -180,7 +212,8 @@ area we are interested in. <7> garbage collect leftover objects from reverted pull. ------------ -* Branch off of a specific tag. +Branch off of a specific tag:: ++ ------------ $ git checkout -b private2.6.14 v2.6.14 <1> $ edit/compile/test; git commit -a @@ -219,7 +252,8 @@ commands in addition to the ones needed by participants. Examples ~~~~~~~~ -* My typical GIT day. +My typical GIT day:: ++ ------------ $ git status <1> $ git show-branch <2> @@ -231,16 +265,17 @@ $ git checkout master $ git am -3 -i -s -u ./+to-apply <4> $ compile/test $ git checkout -b hold/linus && git am -3 -i -s -u ./+hold-linus <5> -$ git checkout pu && git reset --hard master <6> -$ git pull . topic/one topic/two && git pull . hold/linus <7> +$ git checkout topic/one && git rebase master <6> +$ git checkout pu && git reset --hard master <7> +$ git pull . topic/one topic/two && git pull . hold/linus <8> $ git fetch ko master:refs/tags/ko-master && - git show-branch master ko-master <8> -$ git push ko <9> + git show-branch master ko-master <9> +$ git push ko <10> $ git checkout maint -$ git cherry-pick master~4 <10> +$ git cherry-pick master~4 <11> $ compile/test -$ git tag -s -m 'GIT 0.99.9x' v0.99.9x <11> -$ git push ko v0.99.9x <12> +$ git tag -s -m 'GIT 0.99.9x' v0.99.9x <12> +$ git push ko v0.99.9x <13> <1> see what I was in the middle of doing, if any. <2> see what topic branches I have and think about how ready @@ -250,14 +285,16 @@ that are not quite ready. <4> apply them, interactively, with my sign-offs. <5> create topic branch as needed and apply, again with my sign-offs. -<6> restart "pu" every time from the master. -<7> and bundle topic branches still cooking. -<8> make sure I did not accidentally rewound master beyond what I +<6> rebase internal topic branch that has not been merged to the +master, nor exposed as a part of a stable branch. +<7> restart "pu" every time from the master. +<8> and bundle topic branches still cooking. +<9> make sure I did not accidentally rewound master beyond what I already pushed out. -<9> push out the bleeding edge. -<10> backport a critical fix. -<11> create a signed tag. -<12> push the tag out. +<10> push out the bleeding edge. +<11> backport a critical fix. +<12> create a signed tag. +<13> push the tag out. ------------ @@ -276,3 +313,25 @@ and maintain access to the repository by developers. * link:howto/update-hook-example.txt[update hook howto] has a good example of managing a shared central repository. + +Examples +~~~~~~~~ + +Run git-daemon to serve /pub/scm from inetd:: ++ +------------ +$ grep git /etc/inet.conf +git stream tcp nowait nobody /usr/bin/git-daemon git-daemon --inetd --syslog --export-all /pub/scm +------------ + +Give push/pull only access to developers:: ++ +------------ +$ grep git /etc/shells +/usr/bin/git-shell +$ grep git /etc/passwd +alice:x:1000:1000::/home/alice:/usr/bin/git-shell +bob:x:1001:1001::/home/bob:/usr/bin/git-shell +cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell +david:x:1003:1003::/home/david:/usr/bin/git-shell +------------ diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt index 6645e82b84..a415fe24c3 100644 --- a/Documentation/git-am.txt +++ b/Documentation/git-am.txt @@ -69,7 +69,7 @@ recover from this in one of two ways: . hand resolve the conflict in the working directory, and update the index file to bring it in a state that the patch should - have produced. Then run the command with '--resume' option. + have produced. Then run the command with '--resolved' option. The command refuses to process new mailboxes while `.dotest` directory exists, so if you decide to start over from scratch, diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 98014f6d9b..d20b475735 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -32,6 +32,32 @@ start-point:: Where to create the branch; defaults to HEAD. This option has no meaning with -d and -D. + +Examples +~~~~~~~~ + +Start development off of a know tag:: ++ +------------ +$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6 +$ cd my2.6 +$ git branch my2.6.14 v2.6.14 <1> +$ git checkout my2.6.14 + +<1> These two steps are the same as "checkout -b my2.6.14 v2.6.14". +------------ + +Delete unneeded branch:: ++ +------------ +$ git clone git://git.kernel.org/.../git.git my.git +$ cd my.git +$ git branch -D todo <1> + +<1> delete todo branch even if the "master" branch does not have all +commits from todo branch. +------------ + Author ------ Written by Linus Torvalds and Junio C Hamano diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index b7bb1b4c74..9442c66b18 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -50,10 +50,14 @@ the `Makefile` to two revisions back, deletes hello.c by mistake, and gets it back from the index. ------------ -$ git checkout master -$ git checkout master~2 Makefile +$ git checkout master <1> +$ git checkout master~2 Makefile <2> $ rm -f hello.c -$ git checkout hello.c +$ git checkout hello.c <3> + +<1> switch branch +<2> take out a file out of other commit +<3> or "git checkout -- hello.c", as in the next example. ------------ If you have an unfortunate branch that is named `hello.c`, the diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index 83f58ae536..8410a6d381 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -74,10 +74,31 @@ OPTIONS for "host.xz:foo/.git"). Cloning into an existing directory is not allowed. +Examples +~~~~~~~~ + +Clone from upstream:: ++ +------------ +$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6 +$ cd my2.6 +$ make +------------ + + +Make a local clone that borrows from the current directory, without checking things out:: ++ +------------ +$ git clone -l -s -n . ../copy +$ cd copy +$ git show-branch +------------ + Author ------ Written by Linus Torvalds + Documentation -------------- Documentation by Junio C Hamano and the git-list . diff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt index 4486f0c1cf..6deef92508 100644 --- a/Documentation/git-init-db.txt +++ b/Documentation/git-init-db.txt @@ -40,9 +40,12 @@ Start a new git repository for an existing code base:: + ---------------- $ cd /path/to/my/codebase -$ git-init-db ----------------- +$ git-init-db <1> +$ git-add . <2> +<1> prepare /path/to/my/codebase/.git directory +<2> add all existing file to the index +---------------- Author diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt index 6af3a4fdb9..02048918bf 100644 --- a/Documentation/git-reset.txt +++ b/Documentation/git-reset.txt @@ -42,6 +42,76 @@ OPTIONS :: Commit to make the current HEAD. +Examples +~~~~~~~~ + +Undo a commit and redo:: ++ +------------ +$ git commit ... +$ git reset --soft HEAD^ <1> +$ edit <2> +$ git commit -a -c ORIG_HEAD <3> + +<1> This is most often done when you remembered what you +just committed is incomplete, or you misspelled your commit +message, or both. Leaves working tree as it was before "reset". +<2> make corrections to working tree files. +<3> "reset" copies the old head to .git/ORIG_HEAD; redo the +commit by starting with its log message. If you do not need to +edit the message further, you can give -C option instead. +------------ + +Undo commits permanently:: ++ +------------ +$ git commit ... +$ git reset --hard HEAD~3 <1> + +<1> The last three commits (HEAD, HEAD^, and HEAD~2) were bad +and you do not want to ever see them again. Do *not* do this if +you have already given these commits to somebody else. +------------ + +Undo a commit, making it a topic branch:: ++ +------------ +$ git branch topic/wip <1> +$ git reset --hard HEAD~3 <2> +$ git checkout topic/wip <3> + +<1> You have made some commits, but realize they were premature +to be in the "master" branch. You want to continue polishing +them in a topic branch, so create "topic/wip" branch off of the +current HEAD. +<2> Rewind the master branch to get rid of those three commits. +<3> Switch to "topic/wip" branch and keep working. +------------ + +Undo update-index:: ++ +------------ +$ edit <1> +$ git-update-index frotz.c filfre.c +$ mailx <2> +$ git reset <3> +$ git pull git://info.example.com/ nitfol <4> + +<1> you are happily working on something, and find the changes +in these files are in good order. You do not want to see them +when you run "git diff", because you plan to work on other files +and changes with these files are distracting. +<2> somebody asks you to pull, and the changes sounds worthy of merging. +<3> however, you already dirtied the index (i.e. your index does +not match the HEAD commit). But you know the pull you are going +to make does not affect frotz.c nor filfre.c, so you revert the +index changes for these two files. Your changes in working tree +remain there. +<4> then you can pull and merge, leaving frotz.c and filfre.c +changes still in the working tree. +------------ + + Author ------ Written by Junio C Hamano and Linus Torvalds From 76cead391f77142f153ceafcb21ba50f0b09dd15 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Dec 2005 23:55:09 -0800 Subject: [PATCH 10/39] Documentation: fix missing links to git(7) Also move pack protocol description to technical/. Signed-off-by: Junio C Hamano --- Documentation/git-cvsexportcommit.txt | 2 +- Documentation/git.txt | 9 +++++++++ Documentation/{ => technical}/pack-protocol.txt | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) rename Documentation/{ => technical}/pack-protocol.txt (94%) diff --git a/Documentation/git-cvsexportcommit.txt b/Documentation/git-cvsexportcommit.txt index c3da73d1cd..91def2b515 100644 --- a/Documentation/git-cvsexportcommit.txt +++ b/Documentation/git-cvsexportcommit.txt @@ -8,7 +8,7 @@ git-cvsexportcommit - Export a commit to a CVS checkout SYNOPSIS -------- -git-cvsapplycommmit.perl +git-cvsexportcommmit.perl [ -h ] [ -v ] [ -c ] [ -p ] [PARENTCOMMIT] COMMITID diff --git a/Documentation/git.txt b/Documentation/git.txt index 45773db135..d32e6cd745 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -159,6 +159,9 @@ gitlink:git-merge-base[1]:: gitlink:git-name-rev[1]:: Find symbolic names for given revs. +gitlink:git-pack-redundant[1]:: + Find redundant pack files. + gitlink:git-rev-list[1]:: Lists commit objects in reverse chronological order. @@ -211,6 +214,9 @@ gitlink:git-receive-pack[1]:: gitlink:git-send-pack[1]:: Pushes to a remote repository, intelligently. +gitlink:git-http-push[1]:: + Push missing objects using HTTP/DAV. + gitlink:git-shell[1]:: Restricted shell for GIT-only SSH access. @@ -340,6 +346,9 @@ gitlink:git-convert-objects[1]:: gitlink:git-cvsimport[1]:: Salvage your data out of another SCM people love to hate. +gitlink:git-cvsexportcommit[1]:: + Export a single commit to a CVS checkout. + gitlink:git-lost-found[1]:: Recover lost refs that luckily have not yet been pruned. diff --git a/Documentation/pack-protocol.txt b/Documentation/technical/pack-protocol.txt similarity index 94% rename from Documentation/pack-protocol.txt rename to Documentation/technical/pack-protocol.txt index 7d6aec409d..9cd48b4859 100644 --- a/Documentation/pack-protocol.txt +++ b/Documentation/technical/pack-protocol.txt @@ -1,3 +1,6 @@ +Pack transfer protocols +======================= + There are two Pack push-pull protocols. upload-pack (S) | fetch/clone-pack (C) protocol: From 803f498c03b47b1da88cf8f14ba2c374f0fc16d3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 13 Dec 2005 01:54:15 -0800 Subject: [PATCH 11/39] Documentation: diff examples. Signed-off-by: Junio C Hamano --- Documentation/git-diff.txt | 62 ++++++++++++++++++++++++++++++ Documentation/git-format-patch.txt | 9 +++++ 2 files changed, 71 insertions(+) diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt index cf7527f5e9..b04f393bc4 100644 --- a/Documentation/git-diff.txt +++ b/Documentation/git-diff.txt @@ -40,6 +40,68 @@ OPTIONS commands. +EXAMPLES +-------- + +Various ways to check your working tree:: ++ +------------ +$ git diff <1> +$ git diff --cached <2> +$ git diff HEAD <3> + +<1> changes in the working tree since your last git-update-index. +<2> changes between the index and your last commit; what you +would be committing if you run "git commit" without "-a" option. +<3> changes in the working tree since your last commit; what you +would be committing if you run "git commit -a" +------------ + +Comparing with arbitrary commits:: ++ +------------ +$ git diff test <1> +$ git diff HEAD -- ./test <2> +$ git diff HEAD^ HEAD <3> + +<1> instead of using the tip of the current branch, compare with the +tip of "test" branch. +<2> instead of comparing with the tip of "test" branch, compare with +the tip of the curren branch, but limit the comparison to the +file "test". +<3> compare the version before the last commit and the last commit. +------------ + + +Limiting the diff output:: ++ +------------ +$ git diff --diff-filter=MRC <1> +$ git diff --name-status -r <2> +$ git diff arch/i386 include/asm-i386 <3> + +<1> show only modification, rename and copy, but not addition +nor deletion. +<2> show only names and the nature of change, but not actual +diff output. --name-status disables usual patch generation +which in turn also disables recursive behaviour, so without -r +you would only see the directory name if there is a change in a +file in a subdirectory. +<3> limit diff output to named subtrees. +------------ + +Munging the diff output:: ++ +------------ +$ git diff --find-copies-harder -B -C <1> +$ git diff -R <2> + +<1> spend extra cycles to find renames, copies and complete +rewrites (very expensive). +<2> output diff in reverse. +------------ + + Author ------ Written by Linus Torvalds diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index abb8fc89f4..d7ca2dbb22 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -84,6 +84,15 @@ git-format-patch origin:: pulled from origin the last time in a patch form for e-mail submission. +git-format-patch -M -B origin:: + The same as the previous one, except detect and handle + renames and complete rewrites intelligently to produce + renaming patch. A renaming patch reduces the amount of + text output, and generally makes it easier to review + it. Note that the "patch" program does not understand + renaming patch well, so use it only when you know the + recipient uses git to apply your patch. + See Also -------- From 9755afbd9467759bb77a6e5a535791243c5b907d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 13 Dec 2005 02:38:24 -0800 Subject: [PATCH 12/39] Documentation: not learning core git commands. The initial section of tutorial was too heavy on internal workings for the first-time readers, so rewrite the introductory section of git(7) to start with "not learning core git commands" section and refer them to README to grasp the basic concepts, then Everyday to give overview with task/role oriented examples for minimum set of commands, and finally the tutorial. Also add to existing note in the tutorial that many too technical descriptions can be skipped by a casual reader. I initially started to review the tutorial, with the objective of ripping out the detailed technical information altogether, but I found that the level of details in the initial couple of sections that talk about refs and the object database in a hands-on fashion was about rigth, and left all of them there. I feel that reading about fsck-index and repack is too abstract without being aware of these directories and files. Signed-off-by: Junio C Hamano --- Documentation/git.txt | 51 ++++++++++++++++++++++---------------- Documentation/tutorial.txt | 20 ++++++++++++++- 2 files changed, 49 insertions(+), 22 deletions(-) diff --git a/Documentation/git.txt b/Documentation/git.txt index d32e6cd745..482eba7eba 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -33,34 +33,41 @@ OPTIONS environment variable. If no path is given 'git' will print the current setting and then exit. -CORE GIT COMMANDS ------------------ -Before reading this cover to cover, you may want to take a look -at the link:tutorial.html[tutorial] document. If you are -migrating from CVS, link:cvs-migration.html[cvs migration] -document may be helpful after you finish the tutorial. - -The <> section below contains much useful definition -and clarification info - read that first. After that, if you -are interested in using git to manage (version control) + +NOT LEARNING CORE GIT COMMANDS +------------------------------ + +This manual is intended to give complete background information +and internal workings of git, which may be too much for most +people. The <> section below contains much useful +definition and clarification - read that first. + +If you are interested in using git to manage (version control) projects, use link:everyday.html[Everyday GIT] as a guide to the minimum set of commands you need to know for day-to-day work. +Most likely, that will get you started, and you can go a long +way without knowing the low level details too much. + +The link:tutorial.html[tutorial] document covers how things +internally work. + +If you are migrating from CVS, link:cvs-migration.html[cvs +migration] document may be helpful after you finish the +tutorial. After you get the general feel from the tutorial and this overview page, you may want to take a look at the link:howto-index.html[howto] documents. + +CORE GIT COMMANDS +----------------- + If you are writing your own Porcelain, you need to be familiar with most of the low level commands --- I suggest starting from gitlink:git-update-index[1] and gitlink:git-read-tree[1]. -David Greaves -08/05/05 - -Updated by Junio C Hamano on 2005-05-05 and -further on 2005-12-07 to reflect recent changes. - Commands Overview ----------------- The git commands can helpfully be split into those that manipulate @@ -582,14 +589,16 @@ include::../README[] Authors ------- - git's founding father is Linus Torvalds . - The current git nurse is Junio C Hamano . - The git potty was written by Andres Ericsson . - General upbringing is handled by the git-list . +* git's founding father is Linus Torvalds . +* The current git nurse is Junio C Hamano . +* The git potty was written by Andres Ericsson . +* General upbringing is handled by the git-list . Documentation -------------- -Documentation by David Greaves, Junio C Hamano and the git-list . +The documentation for git suite was started by David Greaves +, and later enhanced greatly by the +contributors on the git-list . GIT --- diff --git a/Documentation/tutorial.txt b/Documentation/tutorial.txt index 0827056e1c..a61b824443 100644 --- a/Documentation/tutorial.txt +++ b/Documentation/tutorial.txt @@ -18,7 +18,14 @@ doing. The core git is often called "plumbing", with the prettier user interfaces on top of it called "porcelain". You may not want to use the plumbing directly very often, but it can be good to know what the -plumbing does for when the porcelain isn't flushing... +plumbing does for when the porcelain isn't flushing. + +The material presented here often goes deep describing how things +work internally. If you are mostly interested in using git as a +SCM, you can skip them during your first pass. + +[NOTE] +And those "too deep" descriptions are often marked as Note. Creating a git repository @@ -252,6 +259,17 @@ tree. That's very useful. A common shorthand for `git-diff-files -p` is to just write `git diff`, which will do the same thing. +------------ +$ git diff +diff --git a/hello b/hello +index 557db03..263414f 100644 +--- a/hello ++++ b/hello +@@ -1 +1,2 @@ + Hello World ++It's a new day for git +------------ + Committing git state -------------------- From 0a8b4def9ae9e929a3310b536782a80a7c7644e7 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 13 Dec 2005 15:58:00 -0800 Subject: [PATCH 13/39] git-clone: tell the user a bit more about clone-pack failure. When clone-pack has trouble with the remote, it dies unfriendly "EOF" error message. We cannot tell the reason why it failed from the local end; it could be that the repository did not exist, or configured not to serve over git-daemon, or a network failure. At least, saying clone-pack failed makes it a bit more meaningful. I am not convinced yet that removing the newly created directory is the right thing to do, so this commit leaves the new directory behind. Reported by Sam Ravnborg. Signed-off-by: Junio C Hamano --- git-clone.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git-clone.sh b/git-clone.sh index 699205eb66..e49028f684 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -188,7 +188,10 @@ yes,yes) cd "$D" && case "$upload_pack" in '') git-clone-pack $quiet "$repo" ;; *) git-clone-pack $quiet "$upload_pack" "$repo" ;; - esac + esac || { + echo >&2 "clone-pack from '$repo' failed." + exit 1 + } ;; esac ;; From 9954f5b876abb6118f9bdf1d113239d86acca7bd Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 13 Dec 2005 17:01:23 -0800 Subject: [PATCH 14/39] [PATCH] allow merging any committish Although "git-merge" is advertised as the end-user level command (instead of being a "git-pull" backend), it was not prepared to take tag objects that point at commits and barfed when fed one. Sanitize the input while we validate them, for which we already have a loop. Signed-off-by: Junio C Hamano --- git-merge.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git-merge.sh b/git-merge.sh index a221daa7f4..d25ae4b82d 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -97,11 +97,14 @@ head=$(git-rev-parse --verify "$1"^0) || usage shift # All the rest are remote heads +remoteheads= for remote do - git-rev-parse --verify "$remote"^0 >/dev/null || + remotehead=$(git-rev-parse --verify "$remote"^0) || die "$remote - not something we can merge" + remoteheads="${remoteheads}$remotehead " done +set x $remoteheads ; shift case "$#" in 1) From ed24928e122bad83e62d161087f806fa21c46a59 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Wed, 14 Dec 2005 01:45:40 +0100 Subject: [PATCH 15/39] Make git-send-pack exit with error when some refs couldn't be pushed out In case some refs couldn't be pushed out due to an error (mostly the not-a-proper-subset error), make git-send-pack exit with non-zero status after the push is over (that is, it still tries to push out the rest of the refs). [jc: I adjusted a test for this change.] Signed-off-by: Petr Baudis Signed-off-by: Junio C Hamano --- send-pack.c | 6 +++++- t/t5400-send-pack.sh | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/send-pack.c b/send-pack.c index f61c15c820..6ce0d9f788 100644 --- a/send-pack.c +++ b/send-pack.c @@ -179,6 +179,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec) { struct ref *ref; int new_refs; + int ret = 0; /* No funny business with the matcher */ remote_tail = get_remote_heads(in, &remote_refs, 0, NULL, 1); @@ -232,6 +233,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec) error("remote '%s' object %s does not " "exist on local", ref->name, sha1_to_hex(ref->old_sha1)); + ret = -2; continue; } @@ -245,12 +247,14 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec) error("remote ref '%s' is not a strict " "subset of local ref '%s'.", ref->name, ref->peer_ref->name); + ret = -2; continue; } } memcpy(ref->new_sha1, ref->peer_ref->new_sha1, 20); if (is_zero_sha1(ref->new_sha1)) { error("cannot happen anymore"); + ret = -3; continue; } new_refs++; @@ -267,7 +271,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec) if (new_refs) pack_objects(out, remote_refs); close(out); - return 0; + return ret; } diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index 7fc3bd7d3e..f3694ac3c7 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -43,7 +43,15 @@ test_expect_success setup ' test_expect_success \ 'pushing rewound head should not barf but require --force' ' # should not fail but refuse to update. - git-send-pack ./victim/.git/ master && + if git-send-pack ./victim/.git/ master + then + # now it should fail with Pasky patch + echo >&2 Gaah, it should have failed. + false + else + echo >&2 Thanks, it correctly failed. + true + fi && if cmp victim/.git/refs/heads/master .git/refs/heads/master then # should have been left as it was! From f4f9adaea7e4e46337ae8312f34228a743f0cd89 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 13 Dec 2005 21:39:56 -0800 Subject: [PATCH 16/39] checkout-index: fix checking out specific path. 3bd348aeea24709cd9be4b9d741f79b6014cd7e3 commit broke checking out specific paths. Signed-off-by: Junio C Hamano --- checkout-index.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checkout-index.c b/checkout-index.c index 1e1c9727e0..53dd8cba6f 100644 --- a/checkout-index.c +++ b/checkout-index.c @@ -58,7 +58,7 @@ static int checkout_file(const char *name) while (pos < active_nr) { struct cache_entry *ce = active_cache[pos]; - if (ce_namelen(ce) != namelen && + if (ce_namelen(ce) != namelen || memcmp(ce->name, name, namelen)) break; has_same_name = 1; From 01f49e3453d9960fec62d93bc3a66784f1be4c26 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 14 Dec 2005 00:42:45 -0800 Subject: [PATCH 17/39] Everyday: a bit more examples. Talk about the following as well: * git fetch --tags * Use of "git push" as a one-man distributed development vehicle. * Show example of remotes file for pulling and pushing. * Annotate git-shell setup. * Using Carl's update hook in a CVS-style shared repository. Signed-off-by: Junio C Hamano --- Documentation/everyday.txt | 147 +++++++++++++++++++++++++++++-------- 1 file changed, 118 insertions(+), 29 deletions(-) diff --git a/Documentation/everyday.txt b/Documentation/everyday.txt index 88bd88963a..d8d7a6441a 100644 --- a/Documentation/everyday.txt +++ b/Documentation/everyday.txt @@ -53,7 +53,7 @@ Everybody uses these commands to feed and care git repositories. Examples ~~~~~~~~ -Check health and remove cruft:: +Check health and remove cruft.:: + ------------ $ git fsck-objects <1> @@ -71,11 +71,14 @@ of loose objects accumulation may be a good rule of thumb. <4> after repack, prune removes the duplicate loose objects. ------------ -Repack a small project into single pack:: +Repack a small project into single pack.:: + ------------ $ git repack -a -d <1> $ git prune + +<1> pack all the objects reachable from the refs into one pack +and remove unneeded other packs ------------ @@ -117,7 +120,7 @@ following commands. Examples ~~~~~~~~ -Extract a tarball and create a working tree and a new repository to keep track of it:: +Extract a tarball and create a working tree and a new repository to keep track of it.:: + ------------ $ tar zxf frotz.tar.gz @@ -131,7 +134,7 @@ $ git tag v2.43 <2> <2> make a lightweight, unannotated tag. ------------ -Create a topic branch and develop:: +Create a topic branch and develop.:: + ------------ $ git checkout -b alsa-audio <1> @@ -163,7 +166,8 @@ modification will be caught if you do "commit -a" later. you originally wrote. <9> switch to the master branch. <10> merge a topic branch into your master branch -<11> or --since='aug 1', --max-count=10 +<11> review commit logs; other forms to limit output can be +combined and include --max-count=10 (show 10 commits), --until='2005-12-10'. <12> view only the changes that touch what's in curses/ directory, since v2.43 tag. ------------ @@ -176,20 +180,22 @@ A developer working as a participant in a group project needs to learn how to communicate with others, and uses these commands in addition to the ones needed by a standalone developer. - * gitlink:git-pull[1] from "origin" to keep up-to-date with - the upstream. + * gitlink:git-clone[1] from the upstream to prime your local + repository. + + * gitlink:git-pull[1] and gitlink:git-fetch[1] from "origin" + to keep up-to-date with the upstream. - * gitlink:git-push[1] to shared repository if you adopt CVS + * gitlink:git-push[1] to shared repository, if you adopt CVS style shared repository workflow. * gitlink:git-format-patch[1] to prepare e-mail submission, if you adopt Linux kernel-style public forum workflow. - Examples ~~~~~~~~ -Clone the upstream and work on it. Feed changes to upstream:: +Clone the upstream and work on it. Feed changes to upstream.:: + ------------ $ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6 @@ -201,6 +207,7 @@ $ git whatchanged -p ORIG_HEAD.. arch/i386 include/asm-i386 <4> $ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <5> $ git reset --hard ORIG_HEAD <6> $ git prune <7> +$ git fetch --tags <8> <1> repeat as needed. <2> extract patches from your branch for e-mail submission. @@ -210,9 +217,42 @@ area we are interested in. <5> fetch from a specific branch from a specific repository and and merge. <6> revert the pull. <7> garbage collect leftover objects from reverted pull. +<8> from time to time, obtain official tags from the "origin" +and store them under .git/refs/tags/. +------------ + + +Push into another repository.:: ++ +------------ +satellite$ git clone mothership:frotz/.git frotz <1> +satellite$ cd frotz +satellite$ cat .git/remotes/origin <2> +URL: mothership:frotz/.git +Pull: master:origin +satellite$ echo 'Push: master:satellite' >>.git/remotes/origin <3> +satellite$ edit/compile/test/commit +satellite$ git push origin <4> + +mothership$ cd frotz +mothership$ git checkout master +mothership$ git pull . satellite <5> + +<1> mothership machine has a frotz repository under your home +directory; clone from it to start a repository on the satellite +machine. +<2> clone creates this file by default. It arranges "git pull" +to fetch and store the master branch head of mothership machine +to local "origin" branch. +<3> arrange "git push" to push local "master" branch to +"satellite" branch of the mothership machine. +<4> push will stash our work away on "satellite" branch on the +mothership machine. You could use this as a back-up method. +<5> on mothership machine, merge the work done on the satellite +machine into the master branch. ------------ -Branch off of a specific tag:: +Branch off of a specific tag.:: + ------------ $ git checkout -b private2.6.14 v2.6.14 <1> @@ -252,7 +292,7 @@ commands in addition to the ones needed by participants. Examples ~~~~~~~~ -My typical GIT day:: +My typical GIT day.:: + ------------ $ git status <1> @@ -268,13 +308,12 @@ $ git checkout -b hold/linus && git am -3 -i -s -u ./+hold-linus <5> $ git checkout topic/one && git rebase master <6> $ git checkout pu && git reset --hard master <7> $ git pull . topic/one topic/two && git pull . hold/linus <8> -$ git fetch ko master:refs/tags/ko-master && - git show-branch master ko-master <9> -$ git push ko <10> $ git checkout maint -$ git cherry-pick master~4 <11> +$ git cherry-pick master~4 <9> $ compile/test -$ git tag -s -m 'GIT 0.99.9x' v0.99.9x <12> +$ git tag -s -m 'GIT 0.99.9x' v0.99.9x <10> +$ git fetch ko && git show-branch master maint 'tags/ko-*' <11> +$ git push ko <12> $ git push ko v0.99.9x <13> <1> see what I was in the middle of doing, if any. @@ -289,12 +328,20 @@ sign-offs. master, nor exposed as a part of a stable branch. <7> restart "pu" every time from the master. <8> and bundle topic branches still cooking. -<9> make sure I did not accidentally rewound master beyond what I -already pushed out. -<10> push out the bleeding edge. -<11> backport a critical fix. -<12> create a signed tag. -<13> push the tag out. +<9> backport a critical fix. +<10> create a signed tag. +<11> make sure I did not accidentally rewound master beyond what I +already pushed out. "ko" shorthand points at the repository I have +at kernel.org, and looks like this: +$ cat .git/remotes/ko +URL: kernel.org:/pub/scm/git/git.git +Pull: master:refs/tags/ko-master +Pull: maint:refs/tags/ko-maint +Push: master +Push: +pu +Push: maint +<12> push out the bleeding edge. +<13> push the tag out, too. ------------ @@ -317,21 +364,63 @@ and maintain access to the repository by developers. Examples ~~~~~~~~ -Run git-daemon to serve /pub/scm from inetd:: +Run git-daemon to serve /pub/scm from inetd.:: + ------------ $ grep git /etc/inet.conf -git stream tcp nowait nobody /usr/bin/git-daemon git-daemon --inetd --syslog --export-all /pub/scm +git stream tcp nowait nobody \ + /usr/bin/git-daemon git-daemon --inetd --syslog --export-all /pub/scm ------------ ++ +The actual configuration line should be on one line. -Give push/pull only access to developers:: +Give push/pull only access to developers.:: + ------------ -$ grep git /etc/shells -/usr/bin/git-shell -$ grep git /etc/passwd +$ grep git /etc/passwd <1> alice:x:1000:1000::/home/alice:/usr/bin/git-shell bob:x:1001:1001::/home/bob:/usr/bin/git-shell cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell david:x:1003:1003::/home/david:/usr/bin/git-shell +$ grep git /etc/shells <2> +/usr/bin/git-shell + +<1> log-in shell is set to /usr/bin/git-shell, which does not +allow anything but "git push" and "git pull". The users should +get an ssh access to the machine. +<2> in many distributions /etc/shells needs to list what is used +as the login shell. +------------ + +CVS-style shared repository.:: ++ +------------ +$ grep git /etc/group <1> +git:x:9418:alice,bob,cindy,david +$ cd /home/devo.git +$ ls -l <2> + lrwxrwxrwx 1 david git 17 Dec 4 22:40 HEAD -> refs/heads/master + drwxrwsr-x 2 david git 4096 Dec 4 22:40 branches + -rw-rw-r-- 1 david git 84 Dec 4 22:40 config + -rw-rw-r-- 1 david git 58 Dec 4 22:40 description + drwxrwsr-x 2 david git 4096 Dec 4 22:40 hooks + -rw-rw-r-- 1 david git 37504 Dec 4 22:40 index + drwxrwsr-x 2 david git 4096 Dec 4 22:40 info + drwxrwsr-x 4 david git 4096 Dec 4 22:40 objects + drwxrwsr-x 4 david git 4096 Nov 7 14:58 refs + drwxrwsr-x 2 david git 4096 Dec 4 22:40 remotes +$ ls -l hooks/update <3> + -r-xr-xr-x 1 david git 3536 Dec 4 22:40 update +$ cat info/allowed-users <4> +refs/heads/master alice\|cindy +refs/heads/doc-update bob +refs/tags/v[0-9]* david + +<1> place the developers into the same git group. +<2> and make the shared repository writable by the group. +<3> use update-hook example by Carl from Documentation/howto/ +for branch policy control. +<4> alice and cindy can push into master, only bob can push into doc-update. +david is the release manager and is the only person who can +create and push version tags. ------------ From b3f041fb0f7de167dbb6711b0a231d36c4b5de08 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 13 Dec 2005 22:39:23 -0800 Subject: [PATCH 18/39] git-am support for naked email messages (take 2) This allows git-am to accept single-message files as well as mboxes. Unlike the previous version, this one doesn't need to be explicitly told which one it is; rather, it looks to see if the first line is a From line and uses it to select mbox mode or not. I moved the logic to do all this into git-mailsplit, which got a new user interface as result, although the old interface is still available for backwards compatibility. [jc: applied with two obvious fixes.] Signed-off-by: H. Peter Anvin Signed-off-by: Junio C Hamano --- Documentation/git-mailsplit.txt | 9 ++- git-am.sh | 5 +- mailsplit.c | 103 ++++++++++++++++++++------------ 3 files changed, 75 insertions(+), 42 deletions(-) diff --git a/Documentation/git-mailsplit.txt b/Documentation/git-mailsplit.txt index 03a9477664..e0703e9dfa 100644 --- a/Documentation/git-mailsplit.txt +++ b/Documentation/git-mailsplit.txt @@ -7,7 +7,7 @@ git-mailsplit - Totally braindamaged mbox splitter program. SYNOPSIS -------- -'git-mailsplit' [-d] [] +'git-mailsplit' [-b] [-f] [-d] -o [--] [...] DESCRIPTION ----------- @@ -23,11 +23,18 @@ OPTIONS :: Directory in which to place the individual messages. +-b:: + If any file doesn't begin with a From line, assume it is a + single mail message instead of signalling error. + -d:: Instead of the default 4 digits with leading zeros, different precision can be specified for the generated filenames. +-f:: + Skip the first numbers, for example if -f3 is specified, + start the numbering with 0004. Author ------ diff --git a/git-am.sh b/git-am.sh index 6ed527c7a9..f143b7e782 100755 --- a/git-am.sh +++ b/git-am.sh @@ -164,10 +164,7 @@ else # Start afresh. mkdir -p "$dotest" || exit - # cat does the right thing for us, including '-' to mean - # standard input. - cat "$@" | - git-mailsplit -d$prec "$dotest/" >"$dotest/last" || { + git-mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || { rm -fr "$dotest" exit 1 } diff --git a/mailsplit.c b/mailsplit.c index 189f4ed724..eb58b1ebe4 100644 --- a/mailsplit.c +++ b/mailsplit.c @@ -15,7 +15,7 @@ #include "cache.h" static const char git_mailsplit_usage[] = -"git-mailsplit [-d] [] "; +"git-mailsplit [-d] [-f] [-b] -o ..."; static int is_from_line(const char *line, int len) { @@ -56,14 +56,15 @@ static char buf[4096]; * the Unix "From " line. Write it into the specified * file. */ -static int split_one(FILE *mbox, const char *name) +static int split_one(FILE *mbox, const char *name, int allow_bare) { FILE *output = NULL; int len = strlen(buf); int fd; int status = 0; + int is_bare = !is_from_line(buf, len); - if (!is_from_line(buf, len)) + if (is_bare && !allow_bare) goto corrupt; fd = open(name, O_WRONLY | O_CREAT | O_EXCL, 0666); @@ -88,7 +89,7 @@ static int split_one(FILE *mbox, const char *name) die("cannot read mbox"); } len = strlen(buf); - if (!is_partial && is_from_line(buf, len)) + if (!is_partial && !is_bare && is_from_line(buf, len)) break; /* done with one message */ } fclose(output); @@ -104,54 +105,82 @@ static int split_one(FILE *mbox, const char *name) int main(int argc, const char **argv) { - int i, nr, nr_prec = 4; - FILE *mbox = NULL; + int nr = 0, nr_prec = 4; + int allow_bare = 0; + const char *dir = NULL; + const char **argp; + static const char *stdin_only[] = { "-", NULL }; + char *name; - for (i = 1; i < argc; i++) { - const char *arg = argv[i]; + for (argp = argv+1; *argp; argp++) { + const char *arg = *argp; if (arg[0] != '-') break; /* do flags here */ - if (!strncmp(arg, "-d", 2)) { - nr_prec = strtol(arg + 2, NULL, 10); + if ( arg[1] == 'd' ) { + nr_prec = strtol(arg+2, NULL, 10); if (nr_prec < 3 || 10 <= nr_prec) usage(git_mailsplit_usage); continue; + } else if ( arg[1] == 'f' ) { + nr = strtol(arg+2, NULL, 10); + } else if ( arg[1] == 'b' && !arg[2] ) { + allow_bare = 1; + } else if ( arg[1] == 'o' && arg[2] ) { + dir = arg+2; + } else if ( arg[1] == '-' && !arg[2] ) { + argp++; /* -- marks end of options */ + break; + } else { + die("unknown option: %s", arg); } } - /* Either one remaining arg (dir), or two (mbox and dir) */ - switch (argc - i) { - case 1: - mbox = stdin; - break; - case 2: - if ((mbox = fopen(argv[i], "r")) == NULL) - die("cannot open mbox %s for reading", argv[i]); - break; - default: - usage(git_mailsplit_usage); + if ( !dir ) { + /* Backwards compatibility: if no -o specified, accept + or just */ + switch (argc - (argp-argv)) { + case 1: + dir = argp[0]; + argp = stdin_only; + break; + case 2: + stdin_only[0] = argp[0]; + dir = argp[1]; + argp = stdin_only; + break; + default: + usage(git_mailsplit_usage); + } + } else { + /* New usage: if no more argument, parse stdin */ + if ( !*argp ) + argp = stdin_only; } - if (chdir(argv[argc - 1]) < 0) - usage(git_mailsplit_usage); - nr = 0; - if (fgets(buf, sizeof(buf), mbox) == NULL) - die("cannot read mbox"); + name = xmalloc(strlen(dir) + 2 + 3 * sizeof(nr)); - for (;;) { - char name[10]; + while (*argp) { + const char *file = *argp++; + FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "rt"); + int file_done = 0; - sprintf(name, "%0*d", nr_prec, ++nr); - switch (split_one(mbox, name)) { - case 0: - break; - case 1: - printf("%d\n", nr); - return 0; - default: - exit(1); + if ( !f ) + die ("cannot open mbox %s", file); + + if (fgets(buf, sizeof(buf), f) == NULL) + die("cannot read mbox %s", file); + + while (!file_done) { + sprintf(name, "%s/%0*d", dir, nr_prec, ++nr); + file_done = split_one(f, name, allow_bare); } + + if (f != stdin) + fclose(f); } + + printf("%d\n", nr); + return 0; } From d025524d9d85b057c3caae68a8398eaf7ba3be1a Mon Sep 17 00:00:00 2001 From: Fredrik Kuivinen Date: Sun, 11 Dec 2005 10:55:49 +0100 Subject: [PATCH 19/39] Usage message clean-up, take #2 There were some problems with the usage message clean-up patch series. I hadn't realised that subdirectory aware scripts can't source git-sh-setup. I propose that we change this and let the scripts which are subdirectory aware set a variable, SUBDIRECTORY_OK, before they source git-sh-setup. The scripts will also set USAGE and possibly LONG_USAGE before they source git-sh-setup. If LONG_USAGE isn't set it defaults to USAGE. If we go this way it's easy to catch --help in git-sh-setup, print the (long) usage message to stdout and exit cleanly. git-sh-setup can define a 'usage' shell function which can be called by the scripts to print the short usage string to stderr and exit non-cleanly. It will also be easy to change $0 to basename $0 or something else, if would like to do that sometime in the future. What follows is a patch to convert a couple of the commands to this style. If it's ok with everyone to do it this way I will convert the rest of the scripts too. [jc: thrown in to proposed updates queue for comments.] Signed-off-by: Junio C Hamano --- git-bisect.sh | 24 +++++++++++------------- git-branch.sh | 21 ++++++--------------- git-sh-setup.sh | 34 +++++++++++++++++++++++++++++----- git-status.sh | 11 ++++++++++- 4 files changed, 56 insertions(+), 34 deletions(-) diff --git a/git-bisect.sh b/git-bisect.sh index 05dae8ad13..51e1e4417d 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -1,4 +1,15 @@ #!/bin/sh + +USAGE='[start|bad|good|next|reset|visualize]' +LONG_USAGE='git bisect start [] reset bisect state and start bisection. +git bisect bad [] mark a known-bad revision. +git bisect good [...] mark ... known-good revisions. +git bisect next find next bisection to test and check it out. +git bisect reset [] finish bisection search and go back to branch. +git bisect visualize show bisect status in gitk. +git bisect replay replay bisection log +git bisect log show bisect log.' + . git-sh-setup sq() { @@ -11,19 +22,6 @@ sq() { ' "$@" } -usage() { - echo >&2 'usage: git bisect [start|bad|good|next|reset|visualize] -git bisect start [] reset bisect state and start bisection. -git bisect bad [] mark a known-bad revision. -git bisect good [...] mark ... known-good revisions. -git bisect next find next bisection to test and check it out. -git bisect reset [] finish bisection search and go back to branch. -git bisect visualize show bisect status in gitk. -git bisect replay replay bisection log -git bisect log show bisect log.' - exit 1 -} - bisect_autostart() { test -d "$GIT_DIR/refs/bisect" || { echo >&2 'You need to start by "git bisect start"' diff --git a/git-branch.sh b/git-branch.sh index 5306b2719f..0266f46223 100755 --- a/git-branch.sh +++ b/git-branch.sh @@ -1,21 +1,12 @@ #!/bin/sh -GIT_DIR=`git-rev-parse --git-dir` || exit $? - -die () { - echo >&2 "$*" - exit 1 -} - -usage () { - echo >&2 "usage: $(basename $0)"' [-d ] | [[-f] [start-point]] - -If no arguments, show available branches and mark current branch with a star. +USAGE='[-d ] | [[-f] [start-point]]' +LONG_USAGE='If no arguments, show available branches and mark current branch with a star. If one argument, create a new branch based off of current HEAD. -If two arguments, create a new branch based off of . -' - exit 1 -} +If two arguments, create a new branch based off of .' + +SUBDIRECTORY_OK='Yes' +. git-sh-setup headref=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||') diff --git a/git-sh-setup.sh b/git-sh-setup.sh index b4f10224ba..1e638e493d 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -11,13 +11,37 @@ # exporting it. unset CDPATH -: ${GIT_DIR=.git} -: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"} - die() { echo >&2 "$@" exit 1 } -# Make sure we are in a valid repository of a vintage we understand. -GIT_DIR="$GIT_DIR" git-var GIT_AUTHOR_IDENT >/dev/null || exit +usage() { + die "Usage: $0 $USAGE" +} + +if [ -z "$LONG_USAGE" ] +then + LONG_USAGE="Usage: $0 $USAGE" +else + LONG_USAGE="Usage: $0 $USAGE + +$LONG_USAGE" +fi + +case "$1" in + --h|--he|--hel|--help) + echo "$LONG_USAGE" + exit +esac + +if [ -z "$SUBDIRECTORY_OK" ] +then + : ${GIT_DIR=.git} + : ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"} + + # Make sure we are in a valid repository of a vintage we understand. + GIT_DIR="$GIT_DIR" git-var GIT_AUTHOR_IDENT >/dev/null || exit +else + GIT_DIR=$(git-rev-parse --git-dir) || exit +fi diff --git a/git-status.sh b/git-status.sh index 2dda0c505c..50ccd24efb 100755 --- a/git-status.sh +++ b/git-status.sh @@ -2,7 +2,16 @@ # # Copyright (c) 2005 Linus Torvalds # -GIT_DIR=$(git-rev-parse --git-dir) || exit + +USAGE='' +SUBDIRECTORY_OK='Yes' + +. git-sh-setup + +if [ "$#" != "0" ] +then + usage +fi report () { header="# From aa9dc7afd2fc40466b430b35fc5c82d3c820cb26 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Dec 2005 23:38:47 -0800 Subject: [PATCH 20/39] t3200: branch --help does not die anymore. Signed-off-by: Junio C Hamano --- t/t3200-branch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 36f7749bed..c3de151942 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -16,8 +16,8 @@ test_expect_success \ git-update-index --add A && git-commit -m "Initial commit."' -test_expect_failure \ - 'git branch --help should return error code' \ +test_expect_success \ + 'git branch --help should return success now.' \ 'git-branch --help' test_expect_failure \ From 806f36d4d7caf75b6d3e098cb0353d85d3477c7d Mon Sep 17 00:00:00 2001 From: "freku045@student.liu.se" Date: Tue, 13 Dec 2005 23:30:31 +0100 Subject: [PATCH 21/39] Trivial usage string clean-up Signed-off-by: Fredrik Kuivinen Signed-off-by: Junio C Hamano --- git-add.sh | 13 +++---------- git-applymbox.sh | 6 +----- git-checkout.sh | 6 ++---- git-clone.sh | 2 +- git-commit.sh | 5 +---- git-format-patch.sh | 25 ++++++++----------------- git-grep.sh | 7 +++++-- git-merge.sh | 6 ++---- git-pull.sh | 13 ++----------- git-push.sh | 7 ++----- git-request-pull.sh | 12 +++++------- git-reset.sh | 6 ++---- git-resolve.sh | 6 ++---- git-tag.sh | 14 +++----------- 14 files changed, 39 insertions(+), 89 deletions(-) diff --git a/git-add.sh b/git-add.sh index fdec86d1a4..f719b4b1a8 100755 --- a/git-add.sh +++ b/git-add.sh @@ -1,13 +1,8 @@ #!/bin/sh -die () { - echo >&2 "$*" - exit 1 -} - -usage() { - die "usage: git add [-n] [-v] ..." -} +USAGE='[-n] [-v] ...' +SUBDIRECTORY_OK='Yes' +. git-sh-setup show_only= verbose= @@ -29,8 +24,6 @@ while : ; do shift done -GIT_DIR=$(git-rev-parse --git-dir) || exit - if test -f "$GIT_DIR/info/exclude" then git-ls-files -z \ diff --git a/git-applymbox.sh b/git-applymbox.sh index c686cc8d27..61c8c024c6 100755 --- a/git-applymbox.sh +++ b/git-applymbox.sh @@ -18,13 +18,9 @@ ## ## git-am is supposed to be the newer and better tool for this job. +USAGE='[-u] [-k] [-q] [-m] (-c .dotest/ | mbox) [signoff]' . git-sh-setup -usage () { - echo >&2 "applymbox [-u] [-k] [-q] [-m] (-c .dotest/ | mbox) [signoff]" - exit 1 -} - keep_subject= query_apply= continue= utf8= resume=t while case "$#" in 0) break ;; esac do diff --git a/git-checkout.sh b/git-checkout.sh index 4cf30e2c05..f241d4ba6b 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -1,9 +1,7 @@ #!/bin/sh -. git-sh-setup -usage () { - die "usage: git checkout [-f] [-b ] [] [...]" -} +USAGE='[-f] [-b ] [] [...]' +. git-sh-setup old=$(git-rev-parse HEAD) new= diff --git a/git-clone.sh b/git-clone.sh index e49028f684..280cc2e81e 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -9,7 +9,7 @@ unset CDPATH usage() { - echo >&2 "* git clone [-l [-s]] [-q] [-u ] [-n] []" + echo >&2 "Usage: $0 [-l [-s]] [-q] [-u ] [-n] []" exit 1 } diff --git a/git-commit.sh b/git-commit.sh index 3d250ec853..7e39c107cf 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -3,12 +3,9 @@ # Copyright (c) 2005 Linus Torvalds # +USAGE='[-a] [-s] [-v | --no-verify] [-m | -F | (-C|-c) ] [-e] [...]' . git-sh-setup -usage () { - die 'git commit [-a] [-s] [-v | --no-verify] [-m | -F | (-C|-c) ] [-e] [...]' -} - all= logfile= use_commit= no_edit= log_given= log_message= verify=t signoff= while case "$#" in 0) break;; esac do diff --git a/git-format-patch.sh b/git-format-patch.sh index 921feee59c..01508e3b04 100755 --- a/git-format-patch.sh +++ b/git-format-patch.sh @@ -3,19 +3,8 @@ # Copyright (c) 2005 Junio C Hamano # -. git-sh-setup - -# Force diff to run in C locale. -LANG=C LC_ALL=C -export LANG LC_ALL - -usage () { - echo >&2 "usage: $0"' [-n] [-o dir | --stdout] [--keep-subject] [--mbox] - [--check] [--signoff] [-...] - [--help] - ( from..to ... | upstream [ our-head ] ) - -Prepare each commit with its patch since our-head forked from upstream, +USAGE='[-n | -k] [-o | --stdout] [--signoff] [--check] [--mbox] [--diff-options] []' +LONG_USAGE='Prepare each commit with its patch since our-head forked from upstream, one file per patch, for e-mail submission. Each output file is numbered sequentially from 1, and uses the first line of the commit message (massaged for pathname safety) as the filename. @@ -28,10 +17,12 @@ as "[PATCH N/M] Subject", unless you have only one patch. When --mbox is specified, the output is formatted to resemble UNIX mailbox format, and can be concatenated together for processing -with applymbox. -' - exit 1 -} +with applymbox.' +. git-sh-setup + +# Force diff to run in C locale. +LANG=C LC_ALL=C +export LANG LC_ALL diff_opts= LF=' diff --git a/git-grep.sh b/git-grep.sh index 44c16130bd..2ed8e955d6 100755 --- a/git-grep.sh +++ b/git-grep.sh @@ -3,6 +3,10 @@ # Copyright (c) Linus Torvalds, 2005 # +USAGE='