Merge branch 'maint'

* maint:
  Fix lseek(2) calls with args 2 and 3 swapped
  Honor -p<n> when applying git diffs
  Fix dependency of common-cmds.h
  Fix renaming branch without config file
  DESTDIR support for git/contrib/emacs
  gitweb: Fix bug in "blobdiff" view for split (e.g. file to symlink) patches
  Document --left-right option to rev-list.
  Revert "builtin-archive: use RUN_SETUP"
  rename contrib/hooks/post-receieve-email to contrib/hooks/post-receive-email.
  rerere: make sorting really stable.
  Fix t4200-rerere for white-space from "wc -l"
This commit is contained in:
Junio C Hamano 2007-04-05 16:34:51 -07:00
commit 77e6f5bc10
17 changed files with 99 additions and 20 deletions

View File

@ -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
~~~~~~~~~~~~~~~

View File

@ -727,7 +727,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

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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"

View File

@ -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:

View File

@ -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 $<

2
git.c
View File

@ -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 },

View File

@ -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 {

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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 Q without config should succeed' '
git-branch -m q Q &&
git-branch -m Q q
'
mv .git/config-saved .git/config
git-config branch.s/s.dummy Hello
test_expect_success \

25
t/t4120-apply-popt.sh Executable file
View File

@ -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

View File

@ -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;
-<<<<<<<
-=======
-* END *
->>>>>>>
EOF
git rerere diff > out

View File

@ -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