diff options
31 files changed, 445 insertions, 152 deletions
diff --git a/Documentation/Makefile b/Documentation/Makefile index e82596dcdf..a637d8d559 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -90,14 +90,17 @@ cmds_txt = cmds-ancillaryinterrogators.txt \ cmds-purehelpers.txt \ cmds-foreignscminterface.txt -$(cmds_txt): cmd-list.perl $(MAN1_TXT) +$(cmds_txt): cmd-list.made + +cmd-list.made: cmd-list.perl $(MAN1_TXT) perl ./cmd-list.perl + date >$@ git.7 git.html: git.txt core-intro.txt clean: rm -f *.xml *.xml+ *.html *.html+ *.1 *.7 howto-index.txt howto/*.html doc.dep - rm -f $(cmds_txt) + rm -f $(cmds_txt) *.made %.html : %.txt rm -f $@+ $@ diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl index b54382b2bf..0381590d38 100755 --- a/Documentation/cmd-list.perl +++ b/Documentation/cmd-list.perl @@ -1,8 +1,11 @@ -# +#!/usr/bin/perl -w + +use File::Compare qw(compare); sub format_one { my ($out, $name) = @_; my ($state, $description); + $state = 0; open I, '<', "$name.txt" or die "No such file $name.txt"; while (<I>) { if (/^NAME$/) { @@ -55,7 +58,14 @@ for my $cat (qw(ancillaryinterrogators format_one(\*O, $_); } close O; - rename "$out+", "$out"; + + if (-f "$out" && compare("$out", "$out+") == 0) { + unlink "$out+"; + } + else { + print STDERR "$out\n"; + rename "$out+", "$out"; + } } __DATA__ diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt index b2bc58d851..5f68ee1584 100644 --- a/Documentation/git-bisect.txt +++ b/Documentation/git-bisect.txt @@ -15,7 +15,7 @@ DESCRIPTION The command takes various subcommands, and different options depending on the subcommand: - git bisect start [<paths>...] + git bisect start [<bad> [<good>...]] [--] [<paths>...] git bisect bad <rev> git bisect good <rev> git bisect reset [<branch>] @@ -134,15 +134,26 @@ $ git reset --hard HEAD~3 # try 3 revs before what Then compile and test the one you chose to try. After that, tell bisect what the result was as usual. -Cutting down bisection by giving path parameter to bisect start -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Cutting down bisection by giving more parameters to bisect start +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can further cut down the number of trials if you know what part of the tree is involved in the problem you are tracking down, by giving paths parameters when you say `bisect start`, like this: ------------ -$ git bisect start arch/i386 include/asm-i386 +$ git bisect start -- arch/i386 include/asm-i386 +------------ + +If you know beforehand more than one good commits, you can narrow the +bisect space down without doing the whole tree checkout every time you +give good commits. You give the bad revision immediately after `start` +and then you give all the good revisions you have: + +------------ +$ git bisect start v2.6.20-rc6 v2.6.20-rc4 v2.6.20-rc1 -- + # v2.6.20-rc6 is bad + # v2.6.20-rc4 and v2.6.20-rc1 are good ------------ Bisect run diff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt index 0d59c06139..e0be856546 100644 --- a/Documentation/git-cvsimport.txt +++ b/Documentation/git-cvsimport.txt @@ -9,9 +9,11 @@ git-cvsimport - Salvage your data out of another SCM people love to hate SYNOPSIS -------- [verse] -'git-cvsimport' [-o <branch-for-HEAD>] [-h] [-v] [-d <CVSROOT>] [-s <subst>] - [-p <options-for-cvsps>] [-C <git_repository>] [-i] [-P <file>] - [-m] [-M regex] [<CVS_module>] +'git-cvsimport' [-o <branch-for-HEAD>] [-h] [-v] [-d <CVSROOT>] + [-A <author-conv-file>] [-p <options-for-cvsps>] [-P <file>] + [-C <git_repository>] [-z <fuzz>] [-i] [-k] [-u] [-s <subst>] + [-a] [-m] [-M <regex>] [-S <regex>] [-L <commitlimit>] + [<CVS_module>] DESCRIPTION @@ -30,35 +32,48 @@ any CVS branches, yourself. OPTIONS ------- +-v:: + Verbosity: let 'cvsimport' report what it is doing. + -d <CVSROOT>:: The root of the CVS archive. May be local (a simple path) or remote; currently, only the :local:, :ext: and :pserver: access methods - are supported. + are supported. If not given, git-cvsimport will try to read it + from `CVS/Root`. If no such file exists, it checks for the + `CVSROOT` environment variable. + +<CVS_module>:: + The CVS module you want to import. Relative to <CVSROOT>. + If not given, git-cvsimport tries to read it from + `CVS/Repository`. -C <target-dir>:: The git repository to import to. If the directory doesn't exist, it will be created. Default is the current directory. +-o <branch-for-HEAD>:: + The 'HEAD' branch from CVS is imported to the 'origin' branch within + the git repository, as 'HEAD' already has a special meaning for git. + Use this option if you want to import into a different branch. ++ +Use '-o master' for continuing an import that was initially done by +the old cvs2git tool. + -i:: Import-only: don't perform a checkout after importing. This option ensures the working directory and index remain untouched and will not create them if they do not exist. -k:: - Kill keywords: will extract files with -kk from the CVS archive + Kill keywords: will extract files with '-kk' from the CVS archive to avoid noisy changesets. Highly recommended, but off by default to preserve compatibility with early imported trees. -u:: Convert underscores in tag and branch names to dots. --o <branch-for-HEAD>:: - The 'HEAD' branch from CVS is imported to the 'origin' branch within - the git repository, as 'HEAD' already has a special meaning for git. - Use this option if you want to import into a different branch. -+ -Use '-o master' for continuing an import that was initially done by -the old cvs2git tool. +-s <subst>:: + Substitute the character "/" in branch names with <subst> -p <options-for-cvsps>:: Additional options for cvsps. @@ -66,6 +81,10 @@ the old cvs2git tool. + If you need to pass multiple options, separate them with a comma. +-z <fuzz>:: + Pass the timestamp fuzz factor to cvsps, in seconds. If unset, + cvsps defaults to 300s. + -P <cvsps-output-file>:: Instead of calling cvsps, read the provided cvsps output file. Useful for debugging or when cvsps is being handled outside cvsimport. @@ -77,32 +96,16 @@ If you need to pass multiple options, separate them with a comma. -M <regex>:: Attempt to detect merges based on the commit message with a custom - regex. It can be used with -m to also see the default regexes. + regex. It can be used with '-m' to also see the default regexes. You must escape forward slashes. --v:: - Verbosity: let 'cvsimport' report what it is doing. - -<CVS_module>:: - The CVS module you want to import. Relative to <CVSROOT>. - --h:: - Print a short usage message and exit. - --z <fuzz>:: - Pass the timestamp fuzz factor to cvsps, in seconds. If unset, - cvsps defaults to 300s. - --s <subst>:: - Substitute the character "/" in branch names with <subst> +-S <regex>:: + Skip paths matching the regex. -a:: Import all commits, including recent ones. cvsimport by default skips commits that have a timestamp less than 10 minutes ago. --S <regex>:: - Skip paths matching the regex. - -L <limit>:: Limit the number of commits imported. Workaround for cases where cvsimport leaks memory. @@ -122,14 +125,17 @@ git-cvsimport will make it appear as those authors had their GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL set properly all along. + -For convenience, this data is saved to $GIT_DIR/cvs-authors -each time the -A option is provided and read from that same +For convenience, this data is saved to `$GIT_DIR/cvs-authors` +each time the '-A' option is provided and read from that same file each time git-cvsimport is run. + It is not recommended to use this feature if you intend to export changes back to CVS again later with gitlink:git-cvsexportcommit[1]. +-h:: + Print a short usage message and exit. + OUTPUT ------ If '-v' is specified, the script reports what it is doing. diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index 3fa45b81cc..12b71ed0bb 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -21,6 +21,7 @@ SYNOPSIS [ \--stdin ] [ \--topo-order ] [ \--parents ] + [ \--left-right ] [ \--encoding[=<encoding>] ] [ \--(author|committer|grep)=<pattern> ] [ [\--objects | \--objects-edge] [ \--unpacked ] ] @@ -101,6 +102,36 @@ include::pretty-formats.txt[] Print the parents of the commit. +--left-right:: + + Mark which side of a symmetric diff a commit is reachable from. + Commits from the left side are prefixed with `<` and those from + the right with `>`. If combined with `--boundary`, those + commits are prefixed with `-`. ++ +For example, if you have this topology: ++ +----------------------------------------------------------------------- + y---b---b branch B + / \ / + / . + / / \ + o---x---a---a branch A +----------------------------------------------------------------------- ++ +you would get an output line this: ++ +----------------------------------------------------------------------- + $ git rev-list --left-right --boundary --pretty=oneline A...B + + >bbbbbbb... 3rd on b + >bbbbbbb... 2nd on b + <aaaaaaa... 3rd on a + <aaaaaaa... 2nd on a + -yyyyyyy... 1st on b + -xxxxxxx... 1st on a +----------------------------------------------------------------------- + Diff Formatting ~~~~~~~~~~~~~~~ diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt index 574e9c0e50..d43d2377ec 100644 --- a/Documentation/user-manual.txt +++ b/Documentation/user-manual.txt @@ -1015,7 +1015,7 @@ $ git commit ------------------------------------------------- [[how-to-make-a-commit]] -how to make a commit +How to make a commit -------------------- Creating a new commit takes three steps: @@ -1109,7 +1109,7 @@ $ git diff # difference between the index file and your $ git status # a brief per-file summary of the above. ------------------------------------------------- -creating good commit messages +Creating good commit messages ----------------------------- Though not required, it's a good idea to begin the commit message @@ -1119,7 +1119,7 @@ description. Tools that turn commits into email, for example, use the first line on the Subject line and the rest of the commit in the body. -how to merge +How to merge ------------ You can rejoin two diverging branches of development using @@ -1298,7 +1298,7 @@ the different stages of that file will be "collapsed", after which git-diff will (by default) no longer show diffs for that file. [[undoing-a-merge]] -undoing a merge +Undoing a merge --------------- If you get stuck and decide to just give up and throw the whole mess @@ -385,6 +385,7 @@ endif ifeq ($(uname_S),Darwin) NEEDS_SSL_WITH_CRYPTO = YesPlease NEEDS_LIBICONV = YesPlease + OLD_ICONV = UnfortunatelyYes NO_STRLCPY = YesPlease endif ifeq ($(uname_S),SunOS) @@ -727,7 +728,7 @@ help.o: common-cmds.h $(BUILT_INS): git$X $(QUIET_BUILT_IN)rm -f $@ && ln git$X $@ -common-cmds.h: Documentation/git-*.txt +common-cmds.h: $(wildcard Documentation/git-*.txt) $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh diff --git a/builtin-apply.c b/builtin-apply.c index 6a8292e2a5..4b8311b4de 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -417,7 +417,7 @@ static int gitdiff_hdrend(const char *line, struct patch *patch) static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name, const char *oldnew) { if (!orig_name && !isnull) - return find_name(line, NULL, 1, TERM_TAB); + return find_name(line, NULL, p_value, TERM_TAB); if (orig_name) { int len; @@ -427,7 +427,7 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name, len = strlen(name); if (isnull) die("git-apply: bad git-diff - expected /dev/null, got %s on line %d", name, linenr); - another = find_name(line, NULL, 1, TERM_TAB); + another = find_name(line, NULL, p_value, TERM_TAB); if (!another || memcmp(another, name, len)) die("git-apply: bad git-diff - inconsistent %s filename on line %d", oldnew, linenr); free(another); diff --git a/builtin-archive.c b/builtin-archive.c index 2fae885f5c..8ea6cb1efc 100644 --- a/builtin-archive.c +++ b/builtin-archive.c @@ -252,6 +252,8 @@ int cmd_archive(int argc, const char **argv, const char *prefix) memset(&ar, 0, sizeof(ar)); tree_idx = parse_archive_args(argc, argv, &ar); + if (prefix == NULL) + prefix = setup_git_directory(); argv += tree_idx; parse_treeish_arg(argv, &ar.args, prefix); diff --git a/builtin-branch.c b/builtin-branch.c index a4494ee337..7408285050 100644 --- a/builtin-branch.c +++ b/builtin-branch.c @@ -493,6 +493,7 @@ static void rename_branch(const char *oldname, const char *newname, int force) { char oldref[PATH_MAX], newref[PATH_MAX], logmsg[PATH_MAX*2 + 100]; unsigned char sha1[20]; + char oldsection[PATH_MAX], newsection[PATH_MAX]; if (!oldname) die("cannot rename the current branch while not on any."); @@ -521,6 +522,11 @@ static void rename_branch(const char *oldname, const char *newname, int force) /* no need to pass logmsg here as HEAD didn't really move */ if (!strcmp(oldname, head) && create_symref("HEAD", newref, NULL)) die("Branch renamed to %s, but HEAD is not updated!", newname); + + snprintf(oldsection, sizeof(oldsection), "branch.%s", oldref + 11); + snprintf(newsection, sizeof(newsection), "branch.%s", newref + 11); + if (git_config_rename_section(oldsection, newsection) < 0) + die("Branch is renamed, but update of config-file failed"); } int cmd_branch(int argc, const char **argv, const char *prefix) diff --git a/builtin-rerere.c b/builtin-rerere.c index b463c07f04..8c2c8bdc18 100644 --- a/builtin-rerere.c +++ b/builtin-rerere.c @@ -117,10 +117,13 @@ static int handle_file(const char *path, else if (!prefixcmp(buf, "=======")) hunk = 2; else if (!prefixcmp(buf, ">>>>>>> ")) { + int one_is_longer = (one->nr > two->nr); + int common_len = one_is_longer ? two->nr : one->nr; + int cmp = memcmp(one->ptr, two->ptr, common_len); + hunk_no++; hunk = 0; - if (memcmp(one->ptr, two->ptr, one->nr < two->nr ? - one->nr : two->nr) > 0) { + if ((cmp > 0) || ((cmp == 0) && one_is_longer)) { struct buffer *swap = one; one = two; two = swap; diff --git a/builtin-rev-list.c b/builtin-rev-list.c index f91685a406..09774f9559 100644 --- a/builtin-rev-list.c +++ b/builtin-rev-list.c @@ -35,6 +35,7 @@ static const char rev_list_usage[] = " --header | --pretty\n" " --abbrev=nr | --no-abbrev\n" " --abbrev-commit\n" +" --left-right\n" " special purpose:\n" " --bisect\n" " --bisect-vars" @@ -916,8 +916,8 @@ int git_config_rename_section(const char *old_name, const char *new_name) } if (!(config_file = fopen(config_filename, "rb"))) { - ret = error("Could not open config file!"); - goto out; + /* no config file means nothing to rename, no error */ + goto unlock_and_out; } while (fgets(buf, sizeof(buf), config_file)) { @@ -951,6 +951,7 @@ int git_config_rename_section(const char *old_name, const char *new_name) } } fclose(config_file); + unlock_and_out: if (close(out_fd) || commit_lock_file(lock) < 0) ret = error("Cannot commit config file!"); out: diff --git a/contrib/emacs/Makefile b/contrib/emacs/Makefile index 8554e3967c..98aa0aae9b 100644 --- a/contrib/emacs/Makefile +++ b/contrib/emacs/Makefile @@ -11,8 +11,8 @@ emacsdir = $(prefix)/share/emacs/site-lisp all: $(ELC) install: all - $(INSTALL) -d $(emacsdir) - $(INSTALL_ELC) $(ELC) $(emacsdir) + $(INSTALL) -d $(DESTDIR)$(emacsdir) + $(INSTALL_ELC) $(ELC) $(DESTDIR)$(emacsdir) %.elc: %.el $(EMACS) -batch -f batch-byte-compile $< diff --git a/contrib/hooks/post-receieve-email b/contrib/hooks/post-receive-email index 65160153ee..65160153ee 100644 --- a/contrib/hooks/post-receieve-email +++ b/contrib/hooks/post-receive-email diff --git a/git-bisect.sh b/git-bisect.sh index 11313a7949..85c374e21e 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -1,15 +1,24 @@ #!/bin/sh USAGE='[start|bad|good|next|reset|visualize|replay|log|run]' -LONG_USAGE='git bisect start [<pathspec>] reset bisect state and start bisection. -git bisect bad [<rev>] mark <rev> a known-bad revision. -git bisect good [<rev>...] mark <rev>... known-good revisions. -git bisect next find next bisection to test and check it out. -git bisect reset [<branch>] finish bisection search and go back to branch. -git bisect visualize show bisect status in gitk. -git bisect replay <logfile> replay bisection log. -git bisect log show bisect log. -git bisect run <cmd>... use <cmd>... to automatically bisect.' +LONG_USAGE='git bisect start [<bad> [<good>...]] [--] [<pathspec>...] + reset bisect state and start bisection. +git bisect bad [<rev>] + mark <rev> a known-bad revision. +git bisect good [<rev>...] + mark <rev>... known-good revisions. +git bisect next + find next bisection to test and check it out. +git bisect reset [<branch>] + finish bisection search and go back to branch. +git bisect visualize + show bisect status in gitk. +git bisect replay <logfile> + replay bisection log. +git bisect log + show bisect log. +git bisect run <cmd>... + use <cmd>... to automatically bisect.' . git-sh-setup require_work_tree @@ -70,14 +79,48 @@ bisect_start() { # # Get rid of any old bisect state # - rm -f "$GIT_DIR/refs/heads/bisect" - rm -rf "$GIT_DIR/refs/bisect/" + bisect_clean_state mkdir "$GIT_DIR/refs/bisect" + + # + # Check for one bad and then some good revisions. + # + has_double_dash=0 + for arg; do + case "$arg" in --) has_double_dash=1; break ;; esac + done + orig_args=$(sq "$@") + bad_seen=0 + while [ $# -gt 0 ]; do + arg="$1" + case "$arg" in + --) + shift + break + ;; + *) + rev=$(git-rev-parse --verify "$arg^{commit}" 2>/dev/null) || { + test $has_double_dash -eq 1 && + die "'$arg' does not appear to be a valid revision" + break + } + if [ $bad_seen -eq 0 ]; then + bad_seen=1 + bisect_write_bad "$rev" + else + bisect_write_good "$rev" + fi + shift + ;; + esac + done + + sq "$@" >"$GIT_DIR/BISECT_NAMES" { printf "git-bisect start" - sq "$@" - } >"$GIT_DIR/BISECT_LOG" - sq "$@" >"$GIT_DIR/BISECT_NAMES" + echo "$orig_args" + } >>"$GIT_DIR/BISECT_LOG" + bisect_auto_next } bisect_bad() { @@ -90,12 +133,17 @@ bisect_bad() { *) usage ;; esac || exit - echo "$rev" >"$GIT_DIR/refs/bisect/bad" - echo "# bad: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG" + bisect_write_bad "$rev" echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG" bisect_auto_next } +bisect_write_bad() { + rev="$1" + echo "$rev" >"$GIT_DIR/refs/bisect/bad" + echo "# bad: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG" +} + bisect_good() { bisect_autostart case "$#" in @@ -106,35 +154,54 @@ bisect_good() { for rev in $revs do rev=$(git-rev-parse --verify "$rev^{commit}") || exit - echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev" - echo "# good: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG" + bisect_write_good "$rev" echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG" + done bisect_auto_next } +bisect_write_good() { + rev="$1" + echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev" + echo "# good: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG" +} + bisect_next_check() { - next_ok=no - test -f "$GIT_DIR/refs/bisect/bad" && - case "$(cd "$GIT_DIR" && echo refs/bisect/good-*)" in - refs/bisect/good-\*) ;; - *) next_ok=yes ;; - esac - case "$next_ok,$1" in - no,) false ;; - no,fail) - THEN='' - test -d "$GIT_DIR/refs/bisect" || { - echo >&2 'You need to start by "git bisect start".' - THEN='then ' - } - echo >&2 'You '$THEN'need to give me at least one good' \ - 'and one bad revisions.' - echo >&2 '(You can use "git bisect bad" and' \ - '"git bisect good" for that.)' - exit 1 ;; + missing_good= missing_bad= + git show-ref -q --verify refs/bisect/bad || missing_bad=t + test -n "$(git for-each-ref "refs/bisect/good-*")" || missing_good=t + + case "$missing_good,$missing_bad,$1" in + ,,*) + : have both good and bad - ok + ;; + *,) + # do not have both but not asked to fail - just report. + false + ;; + t,,good) + # have bad but not good. we could bisect although + # this is less optimum. + echo >&2 'Warning: bisecting only with a bad commit.' + if test -t 0 + then + printf >&2 'Are you sure [Y/n]? ' + case "$(read yesno)" in [Nn]*) exit 1 ;; esac + fi + : bisect without good... + ;; *) - true ;; + THEN='' + test -d "$GIT_DIR/refs/bisect" || { + echo >&2 'You need to start by "git bisect start".' + THEN='then ' + } + echo >&2 'You '$THEN'need to give me at least one good' \ + 'and one bad revisions.' + echo >&2 '(You can use "git bisect bad" and' \ + '"git bisect good" for that.)' + exit 1 ;; esac } @@ -145,27 +212,32 @@ bisect_auto_next() { bisect_next() { case "$#" in 0) ;; *) usage ;; esac bisect_autostart - bisect_next_check fail + bisect_next_check good + bad=$(git-rev-parse --verify refs/bisect/bad) && - good=$(git-rev-parse --sq --revs-only --not \ - $(cd "$GIT_DIR" && ls refs/bisect/good-*)) && - rev=$(eval "git-rev-list --bisect $good $bad -- $(cat "$GIT_DIR/BISECT_NAMES")") || exit - if [ -z "$rev" ]; then - echo "$bad was both good and bad" - exit 1 + good=$(git for-each-ref --format='^%(objectname)' \ + "refs/bisect/good-*" | tr '[\012]' ' ') && + eval="git-rev-list --bisect-vars $good $bad --" && + eval="$eval $(cat "$GIT_DIR/BISECT_NAMES")" && + eval=$(eval "$eval") && + eval "$eval" || exit + + if [ -z "$bisect_rev" ]; then + echo "$bad was both good and bad" + exit 1 fi - if [ "$rev" = "$bad" ]; then - echo "$rev is first bad commit" - git-diff-tree --pretty $rev - exit 0 + if [ "$bisect_rev" = "$bad" ]; then + echo "$bisect_rev is first bad commit" + git-diff-tree --pretty $bisect_rev + exit 0 fi - nr=$(eval "git-rev-list $rev $good -- $(cat $GIT_DIR/BISECT_NAMES)" | wc -l) || exit - echo "Bisecting: $nr revisions left to test after this" - echo "$rev" > "$GIT_DIR/refs/heads/new-bisect" + + echo "Bisecting: $bisect_nr revisions left to test after this" + echo "$bisect_rev" >"$GIT_DIR/refs/heads/new-bisect" git checkout -q new-bisect || exit mv "$GIT_DIR/refs/heads/new-bisect" "$GIT_DIR/refs/heads/bisect" && GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD refs/heads/bisect - git-show-branch "$rev" + git-show-branch "$bisect_rev" } bisect_visualize() { @@ -190,14 +262,19 @@ bisect_reset() { usage ;; esac if git checkout "$branch"; then - rm -fr "$GIT_DIR/refs/bisect" - rm -f "$GIT_DIR/refs/heads/bisect" "$GIT_DIR/head-name" - rm -f "$GIT_DIR/BISECT_LOG" - rm -f "$GIT_DIR/BISECT_NAMES" - rm -f "$GIT_DIR/BISECT_RUN" + rm -f "$GIT_DIR/head-name" + bisect_clean_state fi } +bisect_clean_state() { + rm -fr "$GIT_DIR/refs/bisect" + rm -f "$GIT_DIR/refs/heads/bisect" + rm -f "$GIT_DIR/BISECT_LOG" + rm -f "$GIT_DIR/BISECT_NAMES" + rm -f "$GIT_DIR/BISECT_RUN" +} + bisect_replay () { test -r "$1" || { echo >&2 "cannot read $1 for replaying" diff --git a/git-checkout.sh b/git-checkout.sh index a7390e808c..deb0a9a3c7 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -170,7 +170,7 @@ describe_detached_head () { } } -if test -z "$branch$newbranch" && test "$new" != "$old" +if test -z "$branch$newbranch" && test "$new_name" != "$old_name" then detached="$new" if test -n "$oldbranch" && test -z "$quiet" @@ -180,7 +180,7 @@ If you want to create a new branch from this checkout, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b <new_branch_name>" fi -elif test -z "$oldbranch" +elif test -z "$oldbranch" && test "$new" != "$old" then describe_detached_head 'Previous HEAD position was' "$old" fi diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 1a1ba7b1a6..ac74bc51b3 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -32,12 +32,15 @@ $ENV{'TZ'}="UTC"; our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,$opt_M,$opt_A,$opt_S,$opt_L, $opt_a); my (%conv_author_name, %conv_author_email); -sub usage() { +sub usage(;$) { + my $msg = shift; + print(STDERR "Error: $msg\n") if $msg; print STDERR <<END; Usage: ${\basename $0} # fetch/update GIT from CVS [-o branch-for-HEAD] [-h] [-v] [-d CVSROOT] [-A author-conv-file] - [-p opts-for-cvsps] [-C GIT_repository] [-z fuzz] [-i] [-k] [-u] - [-s subst] [-a] [-m] [-M regex] [-S regex] [CVS_module] + [-p opts-for-cvsps] [-P file] [-C GIT_repository] [-z fuzz] [-i] [-k] + [-u] [-s subst] [-a] [-m] [-M regex] [-S regex] [-L commitlimit] + [CVS_module] END exit(1); } @@ -116,7 +119,7 @@ read_repo_config($opts); getopts($opts) or usage(); usage if $opt_h; -@ARGV <= 1 or usage(); +@ARGV <= 1 or usage("You can't specify more than one CVS module"); if ($opt_d) { $ENV{"CVSROOT"} = $opt_d; @@ -129,7 +132,7 @@ if ($opt_d) { } elsif ($ENV{"CVSROOT"}) { $opt_d = $ENV{"CVSROOT"}; } else { - die "CVSROOT needs to be set"; + usage("CVSROOT needs to be set"); } $opt_o ||= "origin"; $opt_s ||= "-"; @@ -148,7 +151,7 @@ if ($#ARGV == 0) { chomp $cvs_tree; close $f; } else { - usage(); + usage("CVS module has to be specified"); } our @mergerx = (); diff --git a/git-send-email.perl b/git-send-email.perl index ae50990d08..1278fcba46 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -595,7 +595,7 @@ foreach my $t (@files) { if ($chain_reply_to || !defined $reply_to || length($reply_to) == 0) { $reply_to = $message_id; if (length $references > 0) { - $references .= " $message_id"; + $references .= "\n $message_id"; } else { $references = "$message_id"; } @@ -226,7 +226,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp) { "add", cmd_add, RUN_SETUP | NOT_BARE }, { "annotate", cmd_annotate, USE_PAGER }, { "apply", cmd_apply }, - { "archive", cmd_archive, RUN_SETUP }, + { "archive", cmd_archive }, { "blame", cmd_blame, RUN_SETUP }, { "branch", cmd_branch, RUN_SETUP }, { "bundle", cmd_bundle }, diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index ea491562c8..e49eb91d69 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -3934,7 +3934,8 @@ sub git_blobdiff { # open patch output open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts, - '-p', $hash_parent_base, $hash_base, + '-p', ($format eq 'html' ? "--full-index" : ()), + $hash_parent_base, $hash_base, "--", (defined $file_parent ? $file_parent : ()), $file_name or die_error(undef, "Open git-diff-tree failed"); } @@ -3969,7 +3970,8 @@ sub git_blobdiff { } # open patch output - open $fd, "-|", git_cmd(), "diff", '-p', @diff_opts, + open $fd, "-|", git_cmd(), "diff", @diff_opts, + '-p', ($format eq 'html' ? "--full-index" : ()), $hash_parent, $hash, "--" or die_error(undef, "Open git-diff failed"); } else { diff --git a/http-fetch.c b/http-fetch.c index 557b40322f..09baedc18a 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -198,7 +198,7 @@ static void start_object_request(struct object_request *obj_req) SHA1_Init(&obj_req->c); if (prev_posn>0) { prev_posn = 0; - lseek(obj_req->local, SEEK_SET, 0); + lseek(obj_req->local, 0, SEEK_SET); ftruncate(obj_req->local, 0); } } diff --git a/http-push.c b/http-push.c index 724720c562..e3f767582b 100644 --- a/http-push.c +++ b/http-push.c @@ -312,7 +312,7 @@ static void start_fetch_loose(struct transfer_request *request) SHA1_Init(&request->c); if (prev_posn>0) { prev_posn = 0; - lseek(request->local_fileno, SEEK_SET, 0); + lseek(request->local_fileno, 0, SEEK_SET); ftruncate(request->local_fileno, 0); } } @@ -828,16 +828,6 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg) goto rollback; } - if (!prefixcmp(oldref, "refs/heads/") && - !prefixcmp(newref, "refs/heads/")) { - char oldsection[1024], newsection[1024]; - - snprintf(oldsection, 1024, "branch.%s", oldref + 11); - snprintf(newsection, 1024, "branch.%s", newref + 11); - if (git_config_rename_section(oldsection, newsection) < 0) - return 1; - } - return 0; rollback: diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 9558bdb631..828d553a4b 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -11,7 +11,7 @@ handled. Specifically, that a bogus branch is not created. . ./test-lib.sh test_expect_success \ - 'prepare an trivial repository' \ + 'prepare a trivial repository' \ 'echo Hello > A && git-update-index --add A && git-commit -m "Initial commit." && @@ -83,6 +83,15 @@ test_expect_failure \ git-branch r && git-branch -m q r/q' +mv .git/config .git/config-saved + +test_expect_success 'git branch -m q q2 without config should succeed' ' + git-branch -m q q2 && + git-branch -m q2 q +' + +mv .git/config-saved .git/config + git-config branch.s/s.dummy Hello test_expect_success \ diff --git a/t/t4120-apply-popt.sh b/t/t4120-apply-popt.sh new file mode 100755 index 0000000000..2f672f30d4 --- /dev/null +++ b/t/t4120-apply-popt.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# +# Copyright (c) 2007 Shawn O. Pearce +# + +test_description='git-apply -p handling.' + +. ./test-lib.sh + +test_expect_success setup ' + mkdir sub && + echo A >sub/file1 && + cp sub/file1 file1 && + git add sub/file1 && + echo B >sub/file1 && + git diff >patch.file && + rm sub/file1 && + rmdir sub +' + +test_expect_success 'apply git diff with -p2' ' + git apply -p2 patch.file +' + +test_done diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index 8b611bbea2..6ba63d7173 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -35,7 +35,8 @@ git commit -q -a -m first git checkout -b second master git show first:a1 | -sed -e 's/To die, t/To die! T/' -e 's/life;$/life./' > a1 +sed -e 's/To die, t/To die! T/' > a1 +echo "* END *" >>a1 git commit -q -a -m second # activate rerere @@ -50,10 +51,10 @@ test_expect_success 'recorded preimage' "grep ======= $rr/preimage" test_expect_success 'no postimage or thisimage yet' \ "test ! -f $rr/postimage -a ! -f $rr/thisimage" -test_expect_success 'preimage have right number of lines' ' +test_expect_success 'preimage has right number of lines' ' cnt=$(sed -ne "/^<<<<<<</,/^>>>>>>>/p" $rr/preimage | wc -l) && - test "$cnt" = 10 + test $cnt = 9 ' @@ -75,10 +76,10 @@ cat > expect << EOF For in that sleep of death what dreams may come When we have shuffled off this mortal coil, Must give us pause: there's the respect + That makes calamity of so long life; -<<<<<<< --That makes calamity of so long life. -======= - That makes calamity of so long life; +-* END * ->>>>>>> EOF git rerere diff > out diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index ac835fe431..b4359df795 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -130,4 +130,8 @@ test_expect_success \ 'validate file contents with prefix' \ 'diff -r a e/prefix/a' +test_expect_success \ + 'git-archive --list outside of a git repo' \ + 'GIT_DIR=some/non-existing/directory git-archive --list' + test_done diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index 35e036a864..083095f7f3 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -123,11 +123,12 @@ test_expect_success \ done' cd "$TRASH" -test_expect_success \ - 'compare delta flavors' \ - 'size_2=`stat -c "%s" test-2-${packname_2}.pack` && - size_3=`stat -c "%s" test-3-${packname_3}.pack` && - test $size_2 -gt $size_3' +test_expect_success 'compare delta flavors' ' + perl -e '\'' + defined($_ = -s $_) or die for @ARGV; + exit 1 if $ARGV[0] <= $ARGV[1]; + '\'' test-2-$packname_2.pack test-3-$packname_3.pack +' rm -fr .git2 mkdir .git2 diff --git a/t/t6030-bisect-run.sh b/t/t6030-bisect-run.sh index 39c72283b5..de3123522a 100755 --- a/t/t6030-bisect-run.sh +++ b/t/t6030-bisect-run.sh @@ -2,7 +2,9 @@ # # Copyright (c) 2007 Christian Couder # -test_description='Tests git-bisect run functionality' +test_description='Tests git-bisect functionality' + +exec </dev/null . ./test-lib.sh @@ -37,11 +39,40 @@ test_expect_success \ HASH3=$(git rev-list HEAD | head -2 | tail -1) && HASH4=$(git rev-list HEAD | head -1)' +test_expect_success 'bisect starts with only one bad' ' + git bisect reset && + git bisect start && + git bisect bad $HASH4 && + git bisect next +' + +test_expect_success 'bisect starts with only one good' ' + git bisect reset && + git bisect start && + git bisect good $HASH1 || return 1 + + if git bisect next + then + echo Oops, should have failed. + false + else + : + fi +' + +test_expect_success 'bisect start with one bad and good' ' + git bisect reset && + git bisect start && + git bisect good $HASH1 && + git bisect bad $HASH4 && + git bisect next +' + # We want to automatically find the commit that # introduced "Another" into hello. test_expect_success \ - 'git bisect run simple case' \ - 'echo "#!/bin/sh" > test_script.sh && + '"git bisect run" simple case' \ + 'echo "#"\!"/bin/sh" > test_script.sh && echo "grep Another hello > /dev/null" >> test_script.sh && echo "test \$? -ne 0" >> test_script.sh && chmod +x test_script.sh && @@ -49,7 +80,21 @@ test_expect_success \ git bisect good $HASH1 && git bisect bad $HASH4 && git bisect run ./test_script.sh > my_bisect_log.txt && - grep "$HASH3 is first bad commit" my_bisect_log.txt' + grep "$HASH3 is first bad commit" my_bisect_log.txt && + git bisect reset' + +# We want to automatically find the commit that +# introduced "Ciao" into hello. +test_expect_success \ + '"git bisect run" with more complex "git bisect start"' \ + 'echo "#"\!"/bin/sh" > test_script.sh && + echo "grep Ciao hello > /dev/null" >> test_script.sh && + echo "test \$? -ne 0" >> test_script.sh && + chmod +x test_script.sh && + git bisect start $HASH4 $HASH1 && + git bisect run ./test_script.sh > my_bisect_log.txt && + grep "$HASH4 is first bad commit" my_bisect_log.txt && + git bisect reset' # # diff --git a/t/t7201-co.sh b/t/t7201-co.sh index 867bbd26cb..5fa6a45577 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -3,7 +3,20 @@ # Copyright (c) 2006 Junio C Hamano # -test_description='git-checkout tests.' +test_description='git-checkout tests. + +Creates master, forks renamer and side branches from it. +Test switching across them. + + ! [master] Initial A one, A two + * [renamer] Renamer R one->uno, M two + ! [side] Side M one, D two, A three + --- + + [side] Side M one, D two, A three + * [renamer] Renamer R one->uno, M two + +*+ [master] Initial A one, A two + +' . ./test-lib.sh @@ -129,4 +142,52 @@ test_expect_success 'checkout -m with merge conflict' ' ! test -s current ' +test_expect_success 'checkout to detach HEAD' ' + + git checkout -f renamer && git clean && + git checkout renamer^ && + H=$(git rev-parse --verify HEAD) && + M=$(git show-ref -s --verify refs/heads/master) && + test "z$H" = "z$M" && + if git symbolic-ref HEAD >/dev/null 2>&1 + then + echo "OOPS, HEAD is still symbolic???" + false + else + : happy + fi +' + +test_expect_success 'checkout to detach HEAD with branchname^' ' + + git checkout -f master && git clean && + git checkout renamer^ && + H=$(git rev-parse --verify HEAD) && + M=$(git show-ref -s --verify refs/heads/master) && + test "z$H" = "z$M" && + if git symbolic-ref HEAD >/dev/null 2>&1 + then + echo "OOPS, HEAD is still symbolic???" + false + else + : happy + fi +' + +test_expect_success 'checkout to detach HEAD with HEAD^0' ' + + git checkout -f master && git clean && + git checkout HEAD^0 && + H=$(git rev-parse --verify HEAD) && + M=$(git show-ref -s --verify refs/heads/master) && + test "z$H" = "z$M" && + if git symbolic-ref HEAD >/dev/null 2>&1 + then + echo "OOPS, HEAD is still symbolic???" + false + else + : happy + fi +' + test_done |