* [PATCH] Teach git-stash to "apply --index"
From: Johannes Schindelin @ 2007-07-02 11:14 UTC (permalink / raw)
To: git, gitster
When given this subcommand, git-stash will try to merge the stashed
index into the current one. Only trivial merges are possible, since
we have no index for the index ;-) If a trivial merge is not possible,
git-stash will bail out with a hint to skip the --index option.
For good measure, finally include a test case.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
I am not quite sure if this should not be the default, with
--skip-index to turn it off if the trivial index merge fails,
and the user might be interested only in the working directory
changes anyway.
Comments?
git-stash.sh | 21 ++++++++++++++++
t/t3903-stash.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 89 insertions(+), 1 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index 04ce30a..45ad2f4 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -98,6 +98,13 @@ apply_stash () {
git-diff-files --quiet ||
die 'Cannot restore on top of a dirty state'
+ unstash_index=
+ case "$1" in
+ --index)
+ unstash_index=t
+ shift
+ esac
+
# current index state
c_tree=$(git-write-tree) ||
die 'Cannot apply a stash in the middle of a merge'
@@ -107,6 +114,15 @@ apply_stash () {
b_tree=$(git-rev-parse --verify "$s^:") ||
die "$*: no valid stashed state found"
+ test -z "$unstash_index" || {
+ git diff --binary $s^2^..$s^2 | git apply --cached
+ test $? -ne 0 &&
+ die 'Conflicts in index. Try without --index.'
+ unstashed_index_tree=$(git-write-tree) ||
+ die 'Could not save index tree'
+ git reset
+ }
+
eval "
GITHEAD_$w_tree='Stashed changes' &&
GITHEAD_$c_tree='Updated upstream' &&
@@ -124,9 +140,12 @@ apply_stash () {
die "Cannot unstage modified files"
git-status
rm -f "$a"
+ test -z "$unstash_index" || git read-tree $unstashed_index_tree
else
# Merge conflict; keep the exit status from merge-recursive
- exit
+ status=$?
+ test -z "$unstash_index" || echo 'Index was not unstashed.' >&2
+ exit $status
fi
}
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
new file mode 100755
index 0000000..392ac1c
--- /dev/null
+++ b/t/t3903-stash.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Johannes E Schindelin
+#
+
+test_description='Test git-stash'
+
+. ./test-lib.sh
+
+test_expect_success 'stash some dirty working directory' '
+ echo 1 > file &&
+ git add file &&
+ test_tick &&
+ git commit -m initial &&
+ echo 2 > file &&
+ git add file &&
+ echo 3 > file &&
+ test_tick &&
+ git stash &&
+ git diff-files --quiet &&
+ git diff-index --cached --quiet HEAD
+'
+
+cat > expect << EOF
+diff --git a/file b/file
+index 0cfbf08..00750ed 100644
+--- a/file
++++ b/file
+@@ -1 +1 @@
+-2
++3
+EOF
+
+test_expect_success 'parents of stash' '
+ test $(git rev-parse stash^) = $(git rev-parse HEAD) &&
+ git diff stash^2..stash > output &&
+ diff -u output expect
+'
+
+test_expect_success 'apply needs clean working directory' '
+ echo 4 > other-file &&
+ git add other-file &&
+ echo 5 > other-file
+ ! git stash apply
+'
+
+test_expect_success 'apply stashed changes' '
+ git add other-file &&
+ test_tick &&
+ git commit -m other-file &&
+ git stash apply &&
+ test 3 = $(cat file) &&
+ test 1 = $(git show :file) &&
+ test 1 = $(git show HEAD:file)
+'
+
+test_expect_success 'apply stashed changes (including index)' '
+ git reset --hard HEAD^ &&
+ echo 6 > other-file &&
+ git add other-file &&
+ test_tick &&
+ git commit -m other-file &&
+ git stash apply --index &&
+ test 3 = $(cat file) &&
+ test 2 = $(git show :file) &&
+ test 1 = $(git show HEAD:file)
+'
+
+test_done
^ permalink raw reply related
* Re: [PATCH] git-stash: Make "save" the default operation again
From: Johannes Schindelin @ 2007-07-02 11:15 UTC (permalink / raw)
To: Jeff King
Cc: Junio C Hamano,
しらいしななこ, GIT
In-Reply-To: <20070702110014.GA6490@sigill.intra.peff.net>
Hi,
On Mon, 2 Jul 2007, Jeff King wrote:
> On Mon, Jul 02, 2007 at 11:44:29AM +0100, Johannes Schindelin wrote:
>
> > So, neither "list" nor "apply" are ase often used in practice as
> > "save". The manpage already reflects that, so change the script to the
> > better.
>
> I have to admit that I don't really care all that much, so I'll let you
> guys duke it out.
I do have to admit that I do care. Especially since my alias is no longer
working (having the same name as a git program).
Ciao,
Dscho
^ permalink raw reply
* [PATCH] Test that git add removes stages 1,2,3.
From: Johannes Sixt @ 2007-07-02 11:18 UTC (permalink / raw)
To: git, j.sixt; +Cc: Johannes Sixt
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
git add seems to have a bug, where it doesn't remove stages 1,2,3
if a stage 0 entry is already in the index.
Here is a test (on top of maint) for the kind soul who wants to fix
this border case. Feel free to merge this patch into your patch
that provides the fix.
-- Hannes
t/t3700-add.sh | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index ad8cc7d..d7dd6ca 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -110,4 +110,16 @@ test_expect_success 'check correct prefix detection' '
git add 1/2/a 1/3/b 1/2/c
'
+test_expect_success 'git add removes unmerged entries' '
+ git rm --cached -f file &&
+ for s in 0 1 2 3
+ do
+ echo "100644 0123456789012345678901234567890123456789 $s file"
+ done | git update-index --index-info &&
+ echo new > file &&
+ git add file &&
+ git ls-files --stage | grep "^100644 .* 0 file$" &&
+ ! git ls-files --stage | grep "^100644 .* [^0] file$"
+'
+
test_done
--
1.5.2.2.555.g24e57
^ permalink raw reply related
* [PATCH/amend] Test that git add removes stages 1,2,3.
From: Johannes Sixt @ 2007-07-02 11:23 UTC (permalink / raw)
To: git; +Cc: j.sixt, Johannes Sixt
In-Reply-To: <11833750863127-git-send-email-johannes.sixt@telecom.at>
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
HMPF!
The test in the original post failed for the wrong reason. :-/
-- Hannes
t/t3700-add.sh | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index ad8cc7d..06fc2bf 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -110,4 +110,16 @@ test_expect_success 'check correct prefix detection' '
git add 1/2/a 1/3/b 1/2/c
'
+test_expect_success 'git add removes unmerged entries' '
+ git rm --cached -f file || : ignore failure &&
+ for s in 0 1 2 3
+ do
+ echo "100644 0123456789012345678901234567890123456789 $s file"
+ done | git update-index --index-info &&
+ echo new > file &&
+ git add file &&
+ git ls-files --stage | grep "^100644 .* 0 file$" &&
+ ! git ls-files --stage | grep "^100644 .* [^0] file$"
+'
+
test_done
--
1.5.2.2.555.g24e57
^ permalink raw reply related
* [PATCH] Test 'git add' for unmerged entries when core.symlinks=false.
From: Johannes Sixt @ 2007-07-02 11:28 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: j.sixt, git, Johannes Sixt
In 20314271679e169f324c118c69c8d9e0399feec9 git add was fixed if unmerged
entries are in the index and core.filemode=false. core.symlinks=false is
a similar case, which touches the same code path. Here is a test that
makes sure that the symlink property in the index is preserved, too.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
t/t3700-add.sh | 27 +++++++++++++++++----------
1 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 0d80c6a..e6466d7 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -110,30 +110,37 @@ test_expect_success 'check correct prefix detection' '
git add 1/2/a 1/3/b 1/2/c
'
-test_expect_success 'git add and filemode=0 with unmerged entries' '
- echo 1 > stage1 &&
- echo 2 > stage2 &&
- echo 3 > stage3 &&
+test_expect_success 'git add with filemode=0, symlinks=0, and unmerged entries' '
for s in 1 2 3
do
+ echo $s > stage$s
echo "100755 $(git hash-object -w stage$s) $s file"
+ echo "120000 $(printf $s | git hash-object -w -t blob --stdin) $s symlink"
done | git update-index --index-info &&
git config core.filemode 0 &&
+ git config core.symlinks 0 &&
echo new > file &&
- git add file &&
- git ls-files --stage | grep "^100755 .* 0 file$"
+ echo new > symlink &&
+ git add file symlink &&
+ git ls-files --stage | grep "^100755 .* 0 file$" &&
+ git ls-files --stage | grep "^120000 .* 0 symlink$"
'
-test_expect_success 'git add and filemode=0 prefers stage 2 over stage 1' '
- git rm --cached -f file &&
+test_expect_success 'git add with filemode=0, symlinks=0 prefers stage 2 over stage 1' '
+ git rm --cached -f file symlink &&
(
echo "100644 $(git hash-object -w stage1) 1 file"
echo "100755 $(git hash-object -w stage2) 2 file"
+ echo "100644 $(printf $s | git hash-object -w -t blob --stdin) 1 symlink"
+ echo "120000 $(printf $s | git hash-object -w -t blob --stdin) 2 symlink"
) | git update-index --index-info &&
git config core.filemode 0 &&
+ git config core.symlinks 0 &&
echo new > file &&
- git add file &&
- git ls-files --stage | grep "^100755 .* 0 file$"
+ echo new > symlink &&
+ git add file symlink &&
+ git ls-files --stage | grep "^100755 .* 0 file$" &&
+ git ls-files --stage | grep "^120000 .* 0 symlink$"
'
test_done
--
1.5.2.2.555.g24e57
^ permalink raw reply related
* Re: [PATCH] Test that git add removes stages 1,2,3.
From: Johannes Schindelin @ 2007-07-02 11:34 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git, j.sixt
In-Reply-To: <11833750863127-git-send-email-johannes.sixt@telecom.at>
Hi,
On Mon, 2 Jul 2007, Johannes Sixt wrote:
> git add seems to have a bug, where it doesn't remove stages 1,2,3
> if a stage 0 entry is already in the index.
But how does that happen? I do not know any way to use porcelain to
achieve that bogus state.
AFAIK stages 1,2,3 are only populated when there are conflicts, in which
case there is no stage 0. Literally the only way I see to have both is to
_make_ update-index put them in there.
Pilot error?
Ciao,
Dscho
^ permalink raw reply
* Re: Bug: segfault during git-prune
From: Linus Torvalds @ 2007-07-02 11:45 UTC (permalink / raw)
To: Andy Parkins; +Cc: git
In-Reply-To: <200707021100.16610.andyparkins@gmail.com>
On Mon, 2 Jul 2007, Andy Parkins wrote:
>
> Looking at your patch: is it possible that S_ISDIR() is true for gitlinks as
> well as S_ISGITLINK()? S_ISDIR() is from unistd.h; and is presumably
> something like:
>
> S_ISDIR() { return mode & S_IFDIR; }
No, it's going to be something like "(mode & S_IFMASK) == S_IFDIR", so
that part should be ok.
BUT:
> Given the hints you gave me in your previous reply, I've looked at the
> backtrace again and understood more what's happening.
>
> - mark_reachable_objects() calls add_cache_refs()
> - which uses lookup_blob() to mark every hash in the index as an OBJ_BLOB
> type of hash; including the GITLINK entries.
Yes, this sounds like the real issue (or the remaining issue, at least).
> I think the fault is in add_cache_refs() which assumes that every hash in the
> index is an OBJ_BLOB. I think that add_cache_refs() shouldn't be calling
> lookup_blob() for S_ISGITLINK() index entries. Therefore I think this patch
> is the right one; what do you reckon?
Looks good to me.
> + /*
> + * The index can contain blobs and GITLINKs, GITLINKs are hashes
> + * that don't actually point to objects in the repository, it's
> + * almost guaranteed that they are NOT blobs, so we don't call
> + * lookup_blob() on them, to avoid populating the hash table
> + * with invalid information
> + */
> + if (S_ISGITLINK(ntohl(active_cache[i]->ce_mode)))
> + continue;
Just for clarity, I'd use "process_gitlink()" here (and it would probably
be a good idea to use process_blob() on the blob we look up too), and the
proper tab indentation, but yes, I think you're otherwise exactly right.
Linus
^ permalink raw reply
* Re: [PATCH] Test that git add removes stages 1,2,3.
From: Johannes Sixt @ 2007-07-02 11:47 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Johannes Sixt, git
In-Reply-To: <Pine.LNX.4.64.0707021232510.4438@racer.site>
Johannes Schindelin wrote:
> On Mon, 2 Jul 2007, Johannes Sixt wrote:
>
> > git add seems to have a bug, where it doesn't remove stages 1,2,3
> > if a stage 0 entry is already in the index.
>
> But how does that happen? I do not know any way to use porcelain to
> achieve that bogus state.
I'm aware of that; so I said "border case" in the original post.
> Pilot error?
Oh, yes :) It noticed this when I was tweaking the test for git add with
symlinks=false that I posted.
-- Hannes
^ permalink raw reply
* Re: why does git perpetually complain about include/asm-blackfin/macros.h?
From: Jeff Garzik @ 2007-07-02 12:29 UTC (permalink / raw)
To: Robert P. J. Day
Cc: Linux Kernel Mailing List, Git Mailing List, Linus Torvalds
In-Reply-To: <Pine.LNX.4.64.0707020800010.1972@localhost.localdomain>
Robert P. J. Day wrote:
> for the umpteenth time, after doing a pull, i see this:
>
> $ git diff
> diff --git a/include/asm-blackfin/macros.h b/include/asm-blackfin/macros.h
> deleted file mode 100644
> index e69de29..0000000
> $
I have the same problem. git 1.5.0.6 on Fedora Core 5 or 6.
I even tried a completely fresh clone, but the problem still appears.
Jeff
^ permalink raw reply
* [PATCH] Make git-prune submodule aware (and fix a SEGFAULT in the process)
From: Andy Parkins @ 2007-07-02 12:56 UTC (permalink / raw)
To: git
I ran git-prune on a repository and got this:
$ git-prune
error: Object 228f8065b930120e35fc0c154c237487ab02d64a is a blob, not a commit
Segmentation fault (core dumped)
This repository was a strange one in that it was being used to provide
its own submodule. That is, the repository was cloned into a
subdirectory, an independent branch checked out in that subdirectory,
and then it was marked as a submodule. git-prune then failed in the
above manner.
The problem was that git-prune was not submodule aware in two areas.
Linus said:
> So what happens is that something traverses a tree object, looks at each
> entry, sees that it's not a tree, and tries to look it up as a blob. But
> subprojects are commits, not blobs, and then when you look at the object
> more closely, you get the above kind of object type confusion.
and included a patch to add an S_ISGITLINK() test to reachable.c's
process_tree() function. That fixed the first git-prune error, and
stopped it from trying to process the gitlink entries in trees as if
they were pointers to other trees (and of course failing, because
gitlinks _aren't_ trees). That part of this patch is his.
The second area is add_cache_refs(). This is called before starting the
reachability analysis, and was calling lookup_blob() on every object
hash found in the index. However, it is no longer true that every hash
in the index is a pointer to a blob, some of them are gitlinks, and are
not backed by any object at all, they are commits in another repository.
Normally this bug was not causing any problems, but in the case of the
self-referencing repository described above, it meant that the gitlink
hash was being marked as being of type OBJ_BLOB by add_cache_refs() call
to lookup_blob(). Then later, because that hash was also pointed to by
a ref, add_one_ref() would treat it as a commit; lookup_commit() would
return a NULL because that object was already noted as being an
OBJ_BLOB, not an OBJ_COMMIT; and parse_commit_buffer() would SEGFAULT on
that NULL pointer.
The fix made by this patch is to not blindly call lookup_blob() in
reachable.c's add_cache_refs(), and instead skip any index entries that
are S_ISGITLINK().
Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
The two parts go together logically so I've put them in this single patch
from me, but half of this patch should be credited to Linus. (I don't know
how one deals with multiple authorship on a single commit in git though)
I suspect that Linus has enough credit to keep him happy and won't mind
that I've edited him out in this case :-)
reachable.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/reachable.c b/reachable.c
index ff3dd34..6383401 100644
--- a/reachable.c
+++ b/reachable.c
@@ -21,6 +21,14 @@ static void process_blob(struct blob *blob,
/* Nothing to do, really .. The blob lookup was the important part */
}
+static void process_gitlink(const unsigned char *sha1,
+ struct object_array *p,
+ struct name_path *path,
+ const char *name)
+{
+ /* I don't think we want to recurse into this, really. */
+}
+
static void process_tree(struct tree *tree,
struct object_array *p,
struct name_path *path,
@@ -47,6 +55,8 @@ static void process_tree(struct tree *tree,
while (tree_entry(&desc, &entry)) {
if (S_ISDIR(entry.mode))
process_tree(lookup_tree(entry.sha1), p, &me, entry.path);
+ else if (S_ISGITLINK(entry.mode))
+ process_gitlink(entry.sha1, p, &me, entry.path);
else
process_blob(lookup_blob(entry.sha1), p, &me, entry.path);
}
@@ -159,6 +169,16 @@ static void add_cache_refs(struct rev_info *revs)
read_cache();
for (i = 0; i < active_nr; i++) {
+ /*
+ * The index can contain blobs and GITLINKs, GITLINKs are hashes
+ * that don't actually point to objects in the repository, it's
+ * almost guaranteed that they are NOT blobs, so we don't call
+ * lookup_blob() on them, to avoid populating the hash table
+ * with invalid information
+ */
+ if (S_ISGITLINK(ntohl(active_cache[i]->ce_mode)))
+ continue;
+
lookup_blob(active_cache[i]->sha1);
/*
* We could add the blobs to the pending list, but quite
--
1.5.2.2.253.g2d8b
^ permalink raw reply related
* Re: Bug: segfault during git-prune
From: Andy Parkins @ 2007-07-02 13:25 UTC (permalink / raw)
To: git; +Cc: Linus Torvalds
In-Reply-To: <alpine.LFD.0.98.0707020441460.3323@woody.linux-foundation.org>
On Monday 2007 July 02, Linus Torvalds wrote:
> Just for clarity, I'd use "process_gitlink()" here (and it would probably
> be a good idea to use process_blob() on the blob we look up too), and the
> proper tab indentation, but yes, I think you're otherwise exactly right.
I've pushed it out as-is as a bug fix patch now; and will happilly make the
above change on top. However, I've not understood what all the parameters
are for in the process_XXXX() functions:
static void process_gitlink(const unsigned char *sha1,
struct object_array *p,
struct name_path *path,
const char *name)
the sha1 and name I can read out of the cache_entry structure, but I'm not
sure about the object_array and name_path structures in the context of
add_cache_refs().
Andy
--
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com
^ permalink raw reply
* Re: why does git perpetually complain about include/asm-blackfin/macros.h?
From: Jesper Juhl @ 2007-07-02 13:58 UTC (permalink / raw)
To: Jeff Garzik
Cc: Robert P. J. Day, Linux Kernel Mailing List, Git Mailing List,
Linus Torvalds
In-Reply-To: <4688EF9B.8020405@garzik.org>
On 02/07/07, Jeff Garzik <jeff@garzik.org> wrote:
> Robert P. J. Day wrote:
> > for the umpteenth time, after doing a pull, i see this:
> >
> > $ git diff
> > diff --git a/include/asm-blackfin/macros.h b/include/asm-blackfin/macros.h
> > deleted file mode 100644
> > index e69de29..0000000
> > $
>
> I have the same problem. git 1.5.0.6 on Fedora Core 5 or 6.
>
> I even tried a completely fresh clone, but the problem still appears.
>
I've seen that as well, but in my case doing a
$ git reset --hard master
fixed it.
--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
^ permalink raw reply
* Re: why does git perpetually complain about include/asm-blackfin/macros.h?
From: Jeff Garzik @ 2007-07-02 14:10 UTC (permalink / raw)
To: Jesper Juhl
Cc: Robert P. J. Day, Linux Kernel Mailing List, Git Mailing List,
Linus Torvalds
In-Reply-To: <9a8748490707020658t5e6542ag6edb435dbc4499ab@mail.gmail.com>
Jesper Juhl wrote:
> On 02/07/07, Jeff Garzik <jeff@garzik.org> wrote:
>> Robert P. J. Day wrote:
>> > for the umpteenth time, after doing a pull, i see this:
>> >
>> > $ git diff
>> > diff --git a/include/asm-blackfin/macros.h
>> b/include/asm-blackfin/macros.h
>> > deleted file mode 100644
>> > index e69de29..0000000
>> > $
>>
>> I have the same problem. git 1.5.0.6 on Fedora Core 5 or 6.
>>
>> I even tried a completely fresh clone, but the problem still appears.
>>
> I've seen that as well, but in my case doing a
> $ git reset --hard master
> fixed it.
Sure. git checkout -f fixes it too.
But then it reappears the every time I switch branches.
Jeff
^ permalink raw reply
* Re: why does git perpetually complain about include/asm-blackfin/macros.h?
From: Alex Riesen @ 2007-07-02 14:22 UTC (permalink / raw)
To: Jeff Garzik
Cc: Jesper Juhl, Robert P. J. Day, Linux Kernel Mailing List,
Git Mailing List, Linus Torvalds
In-Reply-To: <4689073D.1020802@garzik.org>
On 7/2/07, Jeff Garzik <jeff@garzik.org> wrote:
> Jesper Juhl wrote:
> > On 02/07/07, Jeff Garzik <jeff@garzik.org> wrote:
> >> Robert P. J. Day wrote:
> >> > for the umpteenth time, after doing a pull, i see this:
> >> >
> >> > $ git diff
> >> > diff --git a/include/asm-blackfin/macros.h
> >> b/include/asm-blackfin/macros.h
> >> > deleted file mode 100644
> >> > index e69de29..0000000
> >> > $
> >>
> >> I have the same problem. git 1.5.0.6 on Fedora Core 5 or 6.
> >>
> >> I even tried a completely fresh clone, but the problem still appears.
> >>
> > I've seen that as well, but in my case doing a
> > $ git reset --hard master
> > fixed it.
>
> Sure. git checkout -f fixes it too.
>
> But then it reappears the every time I switch branches.
>
Do some of your branches miss the commit by which it was removed?
(It was removed in df30b1171714bbf0e55ffe02138be4b8447e4235)
Than it will reappear every time you switch to a branch which still has
the file.
It is somewhat unclear what "reappear" means, though: do you mean
in your working directory (that's what I explained above) or do you
mean: on the commit pointed by HEAD?
In that second case I can only suspect that all your branches point
at the same commit, which is just before the one the file was removed
in...
^ permalink raw reply
* [RFC] Update on builtin-commit
From: Kristian Høgsberg @ 2007-07-02 14:22 UTC (permalink / raw)
To: git
Hi,
Here's an update on the work so far, and I've attached the current state
of the work as a patch. I'm pretty close to making my first commit with
this, and some of the work here is ready to be factored out into a few
stand-alone patches. I'm thinking of the wt-status.[ch] changes and the
read_fd and read_path changes. My plan is to finish this first-pass
porting of the script and then go back and review and split the patch into
a series of commits, but if somebody wants to pick that up now, that'd be
great.
The only steps missing here are
1) Call git-write-tree with the new index
2) Run the post-commit hook
and I need to look into the reflog stuff. But other than that, the port is
mostly complete.
Kristian
---
Makefile | 9 +-
builtin-commit.c | 567 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
builtin.h | 3 +-
cache.h | 3 +-
color.c | 18 +-
color.h | 4 +-
git.c | 3 +-
mktag.c | 8 +-
sha1_file.c | 44 +++--
wt-status.c | 84 ++++----
wt-status.h | 4 +
11 files changed, 667 insertions(+), 80 deletions(-)
create mode 100644 builtin-commit.c
diff --git a/Makefile b/Makefile
index 0f75955..967d5a5 100644
--- a/Makefile
+++ b/Makefile
@@ -198,7 +198,7 @@ BASIC_LDFLAGS =
SCRIPT_SH = \
git-bisect.sh git-checkout.sh \
- git-clean.sh git-clone.sh git-commit.sh \
+ git-clean.sh git-clone.sh \
git-fetch.sh \
git-ls-remote.sh \
git-merge-one-file.sh git-mergetool.sh git-parse-remote.sh \
@@ -257,7 +257,7 @@ EXTRA_PROGRAMS =
BUILT_INS = \
git-format-patch$X git-show$X git-whatchanged$X git-cherry$X \
git-get-tar-commit-id$X git-init$X git-repo-config$X \
- git-fsck-objects$X git-cherry-pick$X \
+ git-fsck-objects$X git-cherry-pick$X git-status$X\
$(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
# what 'all' will build and 'install' will install, in gitexecdir
@@ -332,6 +332,7 @@ BUILTIN_OBJS = \
builtin-check-attr.o \
builtin-checkout-index.o \
builtin-check-ref-format.o \
+ builtin-commit.o \
builtin-commit-tree.o \
builtin-count-objects.o \
builtin-describe.o \
@@ -367,7 +368,6 @@ BUILTIN_OBJS = \
builtin-rev-parse.o \
builtin-revert.o \
builtin-rm.o \
- builtin-runstatus.o \
builtin-shortlog.o \
builtin-show-branch.o \
builtin-stripspace.o \
@@ -791,9 +791,6 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
chmod +x $@+ && \
mv $@+ $@
-git-status: git-commit
- $(QUIET_GEN)cp $< $@+ && mv $@+ $@
-
gitweb/gitweb.cgi: gitweb/gitweb.perl
$(QUIET_GEN)rm -f $@ $@+ && \
sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
diff --git a/builtin-commit.c b/builtin-commit.c
new file mode 100644
index 0000000..4a68cc0
--- /dev/null
+++ b/builtin-commit.c
@@ -0,0 +1,567 @@
+/*
+ * Builtin "git commit"
+ *
+ * Copyright (c) 2007 Kristian Høgsberg <krh@redhat.com>
+ * Based on git-commit.sh by Junio C Hamano and Linus Torvalds
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "cache.h"
+#include "builtin.h"
+#include "diff.h"
+#include "diffcore.h"
+#include "commit.h"
+#include "revision.h"
+#include "wt-status.h"
+#include "run-command.h"
+
+static const char builtin_commit_usage[] =
+ "[-a | --interactive] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [[-i | -o] <path>...]";
+
+static unsigned char head_sha1[20];
+static const char commit_editmsg[] = "COMMIT_EDITMSG";
+
+enum option_type {
+ OPTION_NONE,
+ OPTION_STRING,
+ OPTION_INTEGER,
+ OPTION_LAST,
+};
+
+struct option {
+ enum option_type type;
+ const char *long_name;
+ char short_name;
+ void *value;
+};
+
+static int scan_options(const char ***argv, struct option *options)
+{
+ const char *value, *eq;
+ int i;
+
+ if (**argv == NULL)
+ return 0;
+ if ((**argv)[0] != '-')
+ return 0;
+ if (!strcmp(**argv, "--"))
+ return 0;
+
+ value = NULL;
+ for (i = 0; options[i].type != OPTION_LAST; i++) {
+ if ((**argv)[1] == '-') {
+ if (!prefixcmp(options[i].long_name, **argv + 2)) {
+ if (options[i].type != OPTION_NONE)
+ value = *++(*argv);
+ goto match;
+ }
+
+ eq = strchr(**argv + 2, '=');
+ if (eq && options[i].type != OPTION_NONE &&
+ !strncmp(**argv + 2,
+ options[i].long_name, eq - **argv - 2)) {
+ value = eq + 1;
+ goto match;
+ }
+ }
+
+ if ((**argv)[1] == options[i].short_name) {
+ if ((**argv)[2] == '\0') {
+ if (options[i].type != OPTION_NONE)
+ value = *++(*argv);
+ goto match;
+ }
+
+ if (options[i].type != OPTION_NONE) {
+ value = **argv + 2;
+ goto match;
+ }
+ }
+ }
+
+ usage(builtin_commit_usage);
+
+ match:
+ switch (options[i].type) {
+ case OPTION_NONE:
+ *(int *)options[i].value = 1;
+ break;
+ case OPTION_STRING:
+ if (value == NULL)
+ die("option %s requires a value.", (*argv)[-1]);
+ *(const char **)options[i].value = value;
+ break;
+ case OPTION_INTEGER:
+ if (value == NULL)
+ die("option %s requires a value.", (*argv)[-1]);
+ *(int *)options[i].value = atoi(value);
+ break;
+ default:
+ assert(0);
+ }
+
+ (*argv)++;
+
+ return 1;
+}
+
+static char *logfile, *force_author, *message;
+static char *edit_message, *use_message;
+static int all, edit_flag, also, interactive, only, no_verify, amend, signoff;
+static int quiet, verbose, untracked_files;
+
+static int no_edit;
+const char *only_include_assumed;
+
+static struct option commit_options[] = {
+ { OPTION_STRING, "file", 'F', (void *) &logfile },
+ { OPTION_NONE, "all", 'a', &all },
+ { OPTION_STRING, "author", 0, (void *) &force_author },
+ { OPTION_NONE, "edit", 0, &edit_flag },
+ { OPTION_NONE, "include", 'i', &also },
+ { OPTION_NONE, "interactive", 0, &interactive },
+ { OPTION_NONE, "only", 'o', &only },
+ { OPTION_STRING, "message", 'm', &message },
+ { OPTION_NONE, "no-verify", 'n', &no_verify },
+ { OPTION_NONE, "amend", 0, &amend },
+ { OPTION_STRING, "reedit-message", 'c', &edit_message },
+ { OPTION_STRING, "reuse-message", 'C', &use_message },
+ { OPTION_NONE, "signoff", 's', &signoff },
+ { OPTION_NONE, "quiet", 'q', &signoff },
+ { OPTION_NONE, "verbose", 'v', &verbose },
+ { OPTION_NONE, "untracked-files", 0, &untracked_files },
+ { OPTION_LAST },
+};
+
+/* FIXME: Taken from builtin-add, should be shared. */
+
+static void update_callback(struct diff_queue_struct *q,
+ struct diff_options *opt, void *cbdata)
+{
+ int i, verbose;
+
+ verbose = *((int *)cbdata);
+ for (i = 0; i < q->nr; i++) {
+ struct diff_filepair *p = q->queue[i];
+ const char *path = p->one->path;
+ switch (p->status) {
+ default:
+ die("unexpacted diff status %c", p->status);
+ case DIFF_STATUS_UNMERGED:
+ case DIFF_STATUS_MODIFIED:
+ add_file_to_cache(path, verbose);
+ break;
+ case DIFF_STATUS_DELETED:
+ remove_file_from_cache(path);
+ if (verbose)
+ printf("remove '%s'\n", path);
+ break;
+ }
+ }
+}
+
+static void
+add_files_to_cache(int fd, const char **files, const char *prefix)
+{
+ struct rev_info rev;
+
+ init_revisions(&rev, "");
+ setup_revisions(0, NULL, &rev, NULL);
+ rev.prune_data = get_pathspec(prefix, files);
+ rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
+ rev.diffopt.format_callback = update_callback;
+ rev.diffopt.format_callback_data = &verbose;
+
+ run_diff_files(&rev, 0);
+
+ if (write_cache(fd, active_cache, active_nr) || close(fd))
+ die("unable to write new index file");
+}
+
+static char *
+prepare_index(const char **files, struct lock_file *lk, const char *prefix)
+{
+ int fd;
+ struct tree *tree;
+ struct lock_file *next_index_lock;
+
+ fd = hold_locked_index(lk, 1);
+ if (read_cache() < 0)
+ die("index file corrupt");
+
+ if (all) {
+ add_files_to_cache(fd, files, NULL);
+ return lk->filename;
+ } else if (also) {
+ add_files_to_cache(fd, files, prefix);
+ return lk->filename;
+ }
+
+ if (interactive)
+ /* launch git-add --interactive */;
+
+ if (*files == NULL) {
+ rollback_lock_file(lk);
+ return get_index_file();
+ }
+
+ /*
+ * FIXME: Warn on unknown files. Shell script does
+ *
+ * commit_only=`git-ls-files --error-unmatch -- "$@"`
+ */
+
+ /*
+ * FIXME: shell script does
+ *
+ * git-read-tree --index-output="$TMP_INDEX" -i -m HEAD
+ *
+ * which warns about unmerged files in the index.
+ */
+
+ /* update the user index file */
+ add_files_to_cache(fd, files, prefix);
+
+ tree = parse_tree_indirect(head_sha1);
+ if (!tree)
+ die("failed to unpack HEAD tree object");
+ if (read_tree(tree, 0, NULL))
+ die("failed to read HEAD tree object");
+
+ /* Uh oh, abusing lock_file to create a garbage collected file */
+ next_index_lock = xmalloc(sizeof(*next_index_lock));
+ fd = hold_lock_file_for_update(next_index_lock,
+ git_path("next-index-%d", getpid()), 1);
+ add_files_to_cache(fd, files, prefix);
+
+ return next_index_lock->filename;
+}
+
+static int strip_lines(char *buffer, int len)
+{
+ int blank_lines, i, j;
+ char *eol;
+
+ blank_lines = 1;
+ for (i = 0, j = 0; i < len; i++) {
+ if (blank_lines > 0 && buffer[i] == '#') {
+ eol = strchr(buffer + i, '\n');
+ if (!eol)
+ break;
+
+ i = eol - buffer;
+ continue;
+ }
+
+ if (buffer[i] == '\n') {
+ blank_lines++;
+ if (blank_lines > 1)
+ continue;
+ } else {
+ if (blank_lines > 2)
+ buffer[j++] = '\n';
+ blank_lines = 0;
+ }
+
+ buffer[j++] = buffer[i];
+ }
+
+ if (buffer[j - 1] != '\n')
+ buffer[j++] = '\n';
+
+ return j;
+}
+
+static int run_status(FILE *fp, const char *index_file)
+{
+ struct wt_status s;
+
+ wt_status_prepare(&s);
+
+ if (amend) {
+ s.amend = 1;
+ s.reference = "HEAD^1";
+ }
+ s.verbose = verbose;
+ s.untracked = untracked_files;
+ s.index_file = index_file;
+ s.fp = fp;
+
+ wt_status_print(&s);
+
+ return s.commitable;
+}
+
+static const char sign_off_header[] = "Signed-off-by: ";
+
+static int prepare_log_message(const char *index_file)
+{
+ char *buffer = NULL, *commit;
+ struct stat statbuf;
+ int type, commitable;
+ unsigned long len, size;
+ unsigned char sha1[20];
+ FILE *fp;
+
+ if (message) {
+ buffer = message;
+ len = strlen(message);
+ } else if (logfile && !strcmp(logfile, "-")) {
+ if (isatty(0))
+ fprintf(stderr, "(reading log message from standard input)\n");
+ if (read_fd(0, &buffer, &len))
+ die("could not read log from standard input");
+ } else if (logfile) {
+ if (read_path(logfile, &buffer, &len))
+ die("could not read log file '%s': %s",
+ logfile, strerror(errno));
+ } else if (use_message) {
+ /* git-show unrolled here... or split out to another
+ * function */
+ /* encoding */
+ if (get_sha1(use_message, sha1))
+ die("could not lookup commit %s", use_message);
+ /* check it's a commit */
+ commit = read_sha1_file(sha1, &type, &size);
+ /* filter out headers, write to msg fd */
+ } else if (!stat(git_path("MERGE_MSG"), &statbuf)) {
+ if (read_path(git_path("MERGE_MSG"), &buffer, &len))
+ die("could not read MERGE_MSG: %s", strerror(errno));
+ } else if (!stat(git_path("SQUASH_MSG"), &statbuf)) {
+ if (read_path(git_path("SQUASH_MSG"), &buffer, &len))
+ die("could not read SQUASH_MSG: %s", strerror(errno));
+ }
+
+ if (buffer)
+ len = strip_lines(buffer, len);
+
+ fp = fopen(git_path(commit_editmsg), "w");
+ if (fp == NULL)
+ die("could not open %s\n", git_path(commit_editmsg));
+
+ if (fwrite(buffer, 1, len, fp) < len)
+ die("could not write commit template: %s\n", strerror(errno));
+
+ if (buffer && signoff) {
+ char *bol = strrchr(buffer + len - 1, '\n');
+ const char *info;
+
+ info = git_committer_info(1);
+ if (!bol || prefixcmp(bol, sign_off_header))
+ fprintf(fp, "\n");
+ fprintf(fp, "Signed-off-by: %s\n", git_committer_info(1));
+ }
+
+ if (!stat(git_path("MERGE_HEAD"), &statbuf) && !no_edit) {
+ fprintf(fp,
+ "#\n"
+ "# It looks like you may be committing a MERGE.\n"
+ "# If this is not correct, please remove the file\n"
+ "# %s\n"
+ "# and try again.\n"
+ "#\n",
+ git_path("MERGE_HEAD"));
+ }
+
+ fprintf(fp,
+ "\n"
+ "# Please enter the commit message for your changes.\n"
+ "# (Comment lines starting with '#' will not be included)\n");
+ if (only_include_assumed)
+ fprintf(fp, "# %s\n", only_include_assumed);
+
+ commitable = run_status(fp, index_file);
+
+ fclose(fp);
+
+ return commitable;
+}
+
+void
+determine_author(char **name, char **email)
+{
+ if (use_message) {
+ /* Get author from commit use_message
+ * parse "author Name <email> date"
+ */
+ } else if (force_author) {
+ /* parse "Author <email>" get from force_author */
+ }
+}
+
+static void parse_and_validate_options(const char ***argv)
+{
+ int initial_commit = 0, f = 0;
+ struct stat statbuf;
+
+ git_config(git_status_config);
+
+ (*argv)++;
+ while (scan_options(argv, commit_options))
+ ;
+
+ if (logfile || message || use_message)
+ no_edit = 1;
+
+ if (get_sha1("HEAD", head_sha1))
+ initial_commit = 1;
+
+ /* Sanity check options */
+ if (amend && initial_commit)
+ die("You have nothing to amend.");
+ if (amend && !stat(git_path("MERGE_HEAD"), &statbuf))
+ die("You are in the middle of a merger -- cannot amend.");
+
+ if (use_message)
+ f++;
+ if (edit_message)
+ f++;
+ if (logfile)
+ f++;
+ if (amend)
+ f++;
+ if (f > 1)
+ die("Only one of -c/-C/-F/--amend can be used.");
+ if (message && f > 0)
+ die("Option -m cannot be combined with -c/-C/-F/--amend.");
+
+ if (also && only)
+ die("Only one of --include/--only can be used.");
+ if (!*argv && (also || (only && !amend)))
+ die("No paths with --include/--only does not make sense.");
+ if (!*argv && only && amend)
+ only_include_assumed = "Clever... amending the last one with dirty index.";
+ if (*argv && !also && !only) {
+ only_include_assumed = "Explicit paths specified without -i nor -o; assuming --only paths...";
+ also = 0;
+ }
+
+ if (all && interactive)
+ die("Cannot use -a, --interactive or -i at the same time.");
+ else if (all && **argv)
+ die("Paths with -a does not make sense.");
+ else if (interactive && **argv)
+ die("Paths with --interactive does not make sense.");
+}
+
+int cmd_status(int argc, const char **argv, const char *prefix)
+{
+ const char *index_file;
+ struct lock_file lk;
+ int commitable;
+
+ parse_and_validate_options(&argv);
+
+ index_file = prepare_index(argv, &lk, prefix);
+
+ commitable = run_status(stdout, index_file);
+
+ rollback_lock_file(&lk);
+
+ return commitable ? 0 : 1;
+}
+
+static void launch_editor(const char *path, char **buffer, unsigned long *len)
+{
+ const char *editor, *terminal;
+ struct child_process child;
+ const char *args[3];
+
+ editor = getenv("VISUAL");
+ if (!editor)
+ editor = getenv("EDITOR");
+
+ terminal = getenv("TERM");
+ if (!editor && (!terminal || !strcmp(terminal, "dumb"))) {
+ fprintf(stderr,
+ "Terminal is dumb but no VISUAL nor EDITOR defined.\n"
+ "Please supply the commit log message using either\n"
+ "-m or -F option. A boilerplate log message has\n"
+ "been prepared in $GIT_DIR/COMMIT_EDITMSG\n");
+ exit(1);
+ }
+
+ if (!editor)
+ editor = "vi";
+
+ memset(&child, 0, sizeof(child));
+ child.argv = args;
+ args[0] = editor;
+ args[1] = path;
+ args[2] = NULL;
+
+ if (run_command(&child))
+ die("could not launch editor %s.", editor);
+
+ if (read_path(path, buffer, len))
+ die("could not read commit message file '%s': %s",
+ logfile, strerror(errno));
+
+ *len = strip_lines(*buffer, *len);
+
+ fwrite(*buffer, 1, *len, stderr);
+}
+
+static int run_pre_commit_hook(const char *index_file)
+{
+ static const char pre_commit_hook[] = "hooks/pre-commit";
+ struct child_process hook;
+ const char *argv[2], *env[2];
+ char index[MAXPATH];
+
+ if (access(git_path(pre_commit_hook), X_OK) < 0)
+ return 0;
+
+ argv[0] = git_path(update_hook);
+ argv[1] = NULL;
+ snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
+ env[0] = index;
+ env[1] = NULL;
+
+ memset(&hook, 0, sizeof(hook));
+ hook.argv = argv;
+ hook.no_stdin = 1;
+ hook.stdout_to_stderr = 1;
+ hook.env = env;
+
+ return run_command(&proc);
+}
+
+int cmd_commit(int argc, const char **argv, const char *prefix)
+{
+ int fd;
+ unsigned long len;
+ char *name, *email, *buffer;
+ const char *index_file;
+ struct lock_file lk;
+ struct stat statbuf;
+
+ parse_and_validate_options(&argv);
+
+ index_file = prepare_index(argv, &lk, prefix);
+
+ if (!prepare_log_message(index_file)) {
+ run_status(stdout, index_file);
+ unlink(commit_editmsg);
+ return 1;
+ }
+
+ determine_author(&name, &email);
+
+ if (!no_edit)
+ launch_editor(commit_editmsg, &buffer, &len);
+
+ if (!no_verify && !stat(git_path("hooks/pre-commit"), &statbuf) &&
+ (statbuf.st_mode & S_IFMT) ==
+ ) {
+
+ }
+
+ if (commit_locked_index(&lk))
+ die("failed to write new index");
+
+ return 0;
+}
diff --git a/builtin.h b/builtin.h
index da4834c..7f395da 100644
--- a/builtin.h
+++ b/builtin.h
@@ -23,6 +23,7 @@ extern int cmd_check_attr(int argc, const char **argv, const char *prefix);
extern int cmd_check_ref_format(int argc, const char **argv, const char *prefix);
extern int cmd_cherry(int argc, const char **argv, const char *prefix);
extern int cmd_cherry_pick(int argc, const char **argv, const char *prefix);
+extern int cmd_commit(int argc, const char **argv, const char *prefix);
extern int cmd_commit_tree(int argc, const char **argv, const char *prefix);
extern int cmd_count_objects(int argc, const char **argv, const char *prefix);
extern int cmd_describe(int argc, const char **argv, const char *prefix);
@@ -63,10 +64,10 @@ extern int cmd_rev_list(int argc, const char **argv, const char *prefix);
extern int cmd_rev_parse(int argc, const char **argv, const char *prefix);
extern int cmd_revert(int argc, const char **argv, const char *prefix);
extern int cmd_rm(int argc, const char **argv, const char *prefix);
-extern int cmd_runstatus(int argc, const char **argv, const char *prefix);
extern int cmd_shortlog(int argc, const char **argv, const char *prefix);
extern int cmd_show(int argc, const char **argv, const char *prefix);
extern int cmd_show_branch(int argc, const char **argv, const char *prefix);
+extern int cmd_status(int argc, const char **argv, const char *prefix);
extern int cmd_stripspace(int argc, const char **argv, const char *prefix);
extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix);
extern int cmd_tar_tree(int argc, const char **argv, const char *prefix);
diff --git a/cache.h b/cache.h
index 5e7381e..0403ada 100644
--- a/cache.h
+++ b/cache.h
@@ -245,7 +245,8 @@ extern int ie_match_stat(struct index_state *, struct cache_entry *, struct stat
extern int ie_modified(struct index_state *, struct cache_entry *, struct stat *, int);
extern int ce_path_match(const struct cache_entry *ce, const char **pathspec);
extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path);
-extern int read_pipe(int fd, char** return_buf, unsigned long* return_size);
+extern int read_fd(int fd, char** return_buf, unsigned long* return_size);
+extern int read_path(const char *path, char** return_buf, unsigned long* return_size);
extern int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object);
extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object);
extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);
diff --git a/color.c b/color.c
index 09d82ee..124ba33 100644
--- a/color.c
+++ b/color.c
@@ -135,39 +135,39 @@ int git_config_colorbool(const char *var, const char *value)
return git_config_bool(var, value);
}
-static int color_vprintf(const char *color, const char *fmt,
+static int color_vfprintf(FILE *fp, const char *color, const char *fmt,
va_list args, const char *trail)
{
int r = 0;
if (*color)
- r += printf("%s", color);
- r += vprintf(fmt, args);
+ r += fprintf(fp, "%s", color);
+ r += vfprintf(fp, fmt, args);
if (*color)
- r += printf("%s", COLOR_RESET);
+ r += fprintf(fp, "%s", COLOR_RESET);
if (trail)
- r += printf("%s", trail);
+ r += fprintf(fp, "%s", trail);
return r;
}
-int color_printf(const char *color, const char *fmt, ...)
+int color_fprintf(FILE *fp, const char *color, const char *fmt, ...)
{
va_list args;
int r;
va_start(args, fmt);
- r = color_vprintf(color, fmt, args, NULL);
+ r = color_vfprintf(fp, color, fmt, args, NULL);
va_end(args);
return r;
}
-int color_printf_ln(const char *color, const char *fmt, ...)
+int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...)
{
va_list args;
int r;
va_start(args, fmt);
- r = color_vprintf(color, fmt, args, "\n");
+ r = color_vfprintf(fp, color, fmt, args, "\n");
va_end(args);
return r;
}
diff --git a/color.h b/color.h
index 88bb8ff..6809800 100644
--- a/color.h
+++ b/color.h
@@ -6,7 +6,7 @@
int git_config_colorbool(const char *var, const char *value);
void color_parse(const char *var, const char *value, char *dst);
-int color_printf(const char *color, const char *fmt, ...);
-int color_printf_ln(const char *color, const char *fmt, ...);
+int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
+int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);
#endif /* COLOR_H */
diff --git a/git.c b/git.c
index 29b55a1..4018e3c 100644
--- a/git.c
+++ b/git.c
@@ -237,6 +237,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
{ "check-attr", cmd_check_attr, RUN_SETUP | NOT_BARE },
{ "cherry", cmd_cherry, RUN_SETUP },
{ "cherry-pick", cmd_cherry_pick, RUN_SETUP | NOT_BARE },
+ { "commit", cmd_commit, RUN_SETUP },
{ "commit-tree", cmd_commit_tree, RUN_SETUP },
{ "config", cmd_config },
{ "count-objects", cmd_count_objects, RUN_SETUP },
@@ -279,10 +280,10 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
{ "rev-parse", cmd_rev_parse, RUN_SETUP },
{ "revert", cmd_revert, RUN_SETUP | NOT_BARE },
{ "rm", cmd_rm, RUN_SETUP | NOT_BARE },
- { "runstatus", cmd_runstatus, RUN_SETUP | NOT_BARE },
{ "shortlog", cmd_shortlog, RUN_SETUP | USE_PAGER },
{ "show-branch", cmd_show_branch, RUN_SETUP },
{ "show", cmd_show, RUN_SETUP | USE_PAGER },
+ { "status", cmd_status, RUN_SETUP | NOT_BARE },
{ "stripspace", cmd_stripspace },
{ "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
{ "tar-tree", cmd_tar_tree },
diff --git a/mktag.c b/mktag.c
index b82e377..26b9ebf 100644
--- a/mktag.c
+++ b/mktag.c
@@ -111,8 +111,8 @@ static int verify_tag(char *buffer, unsigned long size)
int main(int argc, char **argv)
{
- unsigned long size = 4096;
- char *buffer = xmalloc(size);
+ unsigned long size;
+ char *buffer;
unsigned char result_sha1[20];
if (argc != 1)
@@ -120,10 +120,8 @@ int main(int argc, char **argv)
setup_git_directory();
- if (read_pipe(0, &buffer, &size)) {
- free(buffer);
+ if (read_fd(0, &buffer, &size))
die("could not read from stdin");
- }
/* Verify it for some basic sanity: it needs to start with
"object <sha1>\ntype\ntagger " */
diff --git a/sha1_file.c b/sha1_file.c
index 2b86086..91e8854 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2286,18 +2286,17 @@ int has_sha1_file(const unsigned char *sha1)
}
/*
- * reads from fd as long as possible into a supplied buffer of size bytes.
- * If necessary the buffer's size is increased using realloc()
+ * reads from fd as long as possible and allocates a buffer to hold
+ * the contents. The buffer and size of the contents is returned in
+ * *return_buf and *return_size. In case of failure, the allocated
+ * buffers are freed, otherwise, the buffer must be freed using xfree.
*
* returns 0 if anything went fine and -1 otherwise
- *
- * NOTE: both buf and size may change, but even when -1 is returned
- * you still have to free() it yourself.
*/
-int read_pipe(int fd, char** return_buf, unsigned long* return_size)
+int read_fd(int fd, char** return_buf, unsigned long* return_size)
{
- char* buf = *return_buf;
- unsigned long size = *return_size;
+ unsigned long size = 4096;
+ char* buf = xmalloc(size);
ssize_t iret;
unsigned long off = 0;
@@ -2315,21 +2314,38 @@ int read_pipe(int fd, char** return_buf, unsigned long* return_size)
*return_buf = buf;
*return_size = off;
- if (iret < 0)
+ if (iret < 0) {
+ free(buf);
+ return -1;
+ }
+
+ return 0;
+}
+
+int read_path(const char *path, char** return_buf, unsigned long* return_size)
+{
+ int fd;
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return -1;
+ if (read_fd(fd, return_buf, return_size)) {
+ close(fd);
return -1;
+ }
+ close(fd);
+
return 0;
}
int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object)
{
- unsigned long size = 4096;
- char *buf = xmalloc(size);
+ unsigned long size;
+ char *buf;
int ret;
- if (read_pipe(fd, &buf, &size)) {
- free(buf);
+ if (read_fd(fd, &buf, &size))
return -1;
- }
if (!type)
type = blob_type;
diff --git a/wt-status.c b/wt-status.c
index 5205420..463ecd7 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -54,29 +54,30 @@ void wt_status_prepare(struct wt_status *s)
s->reference = "HEAD";
}
-static void wt_status_print_cached_header(const char *reference)
+static void wt_status_print_cached_header(struct wt_status *s)
{
const char *c = color(WT_STATUS_HEADER);
- color_printf_ln(c, "# Changes to be committed:");
- if (reference) {
- color_printf_ln(c, "# (use \"git reset %s <file>...\" to unstage)", reference);
+ color_fprintf_ln(s->fp, c, "# Changes to be committed:");
+ if (s->reference) {
+ color_fprintf_ln(s->fp, c, "# (use \"git reset %s <file>...\" to unstage)", s->reference);
} else {
- color_printf_ln(c, "# (use \"git rm --cached <file>...\" to unstage)");
+ color_fprintf_ln(s->fp, c, "# (use \"git rm --cached <file>...\" to unstage)");
}
- color_printf_ln(c, "#");
+ color_fprintf_ln(s->fp, c, "#");
}
-static void wt_status_print_header(const char *main, const char *sub)
+static void wt_status_print_header(struct wt_status *s,
+ const char *main, const char *sub)
{
const char *c = color(WT_STATUS_HEADER);
- color_printf_ln(c, "# %s:", main);
- color_printf_ln(c, "# (%s)", sub);
- color_printf_ln(c, "#");
+ color_fprintf_ln(s->fp, c, "# %s:", main);
+ color_fprintf_ln(s->fp, c, "# (%s)", sub);
+ color_fprintf_ln(s->fp, c, "#");
}
-static void wt_status_print_trailer(void)
+static void wt_status_print_trailer(struct wt_status *s)
{
- color_printf_ln(color(WT_STATUS_HEADER), "#");
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
}
static const char *quote_crlf(const char *in, char *buf, size_t sz)
@@ -108,7 +109,8 @@ static const char *quote_crlf(const char *in, char *buf, size_t sz)
return ret;
}
-static void wt_status_print_filepair(int t, struct diff_filepair *p)
+static void wt_status_print_filepair(struct wt_status *s,
+ int t, struct diff_filepair *p)
{
const char *c = color(t);
const char *one, *two;
@@ -117,36 +119,36 @@ static void wt_status_print_filepair(int t, struct diff_filepair *p)
one = quote_crlf(p->one->path, onebuf, sizeof(onebuf));
two = quote_crlf(p->two->path, twobuf, sizeof(twobuf));
- color_printf(color(WT_STATUS_HEADER), "#\t");
+ color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t");
switch (p->status) {
case DIFF_STATUS_ADDED:
- color_printf(c, "new file: %s", one);
+ color_fprintf(s->fp, c, "new file: %s", one);
break;
case DIFF_STATUS_COPIED:
- color_printf(c, "copied: %s -> %s", one, two);
+ color_fprintf(s->fp, c, "copied: %s -> %s", one, two);
break;
case DIFF_STATUS_DELETED:
- color_printf(c, "deleted: %s", one);
+ color_fprintf(s->fp, c, "deleted: %s", one);
break;
case DIFF_STATUS_MODIFIED:
- color_printf(c, "modified: %s", one);
+ color_fprintf(s->fp, c, "modified: %s", one);
break;
case DIFF_STATUS_RENAMED:
- color_printf(c, "renamed: %s -> %s", one, two);
+ color_fprintf(s->fp, c, "renamed: %s -> %s", one, two);
break;
case DIFF_STATUS_TYPE_CHANGED:
- color_printf(c, "typechange: %s", one);
+ color_fprintf(s->fp, c, "typechange: %s", one);
break;
case DIFF_STATUS_UNKNOWN:
- color_printf(c, "unknown: %s", one);
+ color_fprintf(s->fp, c, "unknown: %s", one);
break;
case DIFF_STATUS_UNMERGED:
- color_printf(c, "unmerged: %s", one);
+ color_fprintf(s->fp, c, "unmerged: %s", one);
break;
default:
die("bug: unhandled diff status %c", p->status);
}
- printf("\n");
+ fprintf(s->fp, "\n");
}
static void wt_status_print_updated_cb(struct diff_queue_struct *q,
@@ -160,14 +162,14 @@ static void wt_status_print_updated_cb(struct diff_queue_struct *q,
if (q->queue[i]->status == 'U')
continue;
if (!shown_header) {
- wt_status_print_cached_header(s->reference);
+ wt_status_print_cached_header(s);
s->commitable = 1;
shown_header = 1;
}
- wt_status_print_filepair(WT_STATUS_UPDATED, q->queue[i]);
+ wt_status_print_filepair(s, WT_STATUS_UPDATED, q->queue[i]);
}
if (shown_header)
- wt_status_print_trailer();
+ wt_status_print_trailer(s);
}
static void wt_status_print_changed_cb(struct diff_queue_struct *q,
@@ -184,18 +186,18 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
msg = use_add_rm_msg;
break;
}
- wt_status_print_header("Changed but not updated", msg);
+ wt_status_print_header(s, "Changed but not updated", msg);
}
for (i = 0; i < q->nr; i++)
- wt_status_print_filepair(WT_STATUS_CHANGED, q->queue[i]);
+ wt_status_print_filepair(s, WT_STATUS_CHANGED, q->queue[i]);
if (q->nr)
- wt_status_print_trailer();
+ wt_status_print_trailer(s);
}
static void wt_read_cache(struct wt_status *s)
{
discard_cache();
- read_cache();
+ read_cache_from(s->index_file);
}
static void wt_status_print_initial(struct wt_status *s)
@@ -209,13 +211,13 @@ static void wt_status_print_initial(struct wt_status *s)
wt_status_print_cached_header(NULL);
}
for (i = 0; i < active_nr; i++) {
- color_printf(color(WT_STATUS_HEADER), "#\t");
- color_printf_ln(color(WT_STATUS_UPDATED), "new file: %s",
+ color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t");
+ color_fprintf_ln(s->fp, color(WT_STATUS_UPDATED), "new file: %s",
quote_crlf(active_cache[i]->name,
buf, sizeof(buf)));
}
if (active_nr)
- wt_status_print_trailer();
+ wt_status_print_trailer(s);
}
static void wt_status_print_updated(struct wt_status *s)
@@ -281,12 +283,12 @@ static void wt_status_print_untracked(struct wt_status *s)
}
if (!shown_header) {
s->workdir_untracked = 1;
- wt_status_print_header("Untracked files",
+ wt_status_print_header(s, "Untracked files",
use_add_to_include_msg);
shown_header = 1;
}
- color_printf(color(WT_STATUS_HEADER), "#\t");
- color_printf_ln(color(WT_STATUS_UNTRACKED), "%.*s",
+ color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t");
+ color_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED), "%.*s",
ent->len, ent->name);
}
}
@@ -316,14 +318,14 @@ void wt_status_print(struct wt_status *s)
branch_name = "";
on_what = "Not currently on any branch.";
}
- color_printf_ln(color(WT_STATUS_HEADER),
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER),
"# %s%s", on_what, branch_name);
}
if (s->is_initial) {
- color_printf_ln(color(WT_STATUS_HEADER), "#");
- color_printf_ln(color(WT_STATUS_HEADER), "# Initial commit");
- color_printf_ln(color(WT_STATUS_HEADER), "#");
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "# Initial commit");
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
wt_status_print_initial(s);
}
else {
@@ -337,7 +339,7 @@ void wt_status_print(struct wt_status *s)
wt_status_print_verbose(s);
if (!s->commitable) {
if (s->amend)
- printf("# No changes\n");
+ fprintf(s->fp, "# No changes\n");
else if (s->workdir_dirty)
printf("no changes added to commit (use \"git add\" and/or \"git commit -a\")\n");
else if (s->workdir_untracked)
diff --git a/wt-status.h b/wt-status.h
index cfea4ae..7744932 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -1,6 +1,8 @@
#ifndef STATUS_H
#define STATUS_H
+#include <stdio.h>
+
enum color_wt_status {
WT_STATUS_HEADER,
WT_STATUS_UPDATED,
@@ -19,6 +21,8 @@ struct wt_status {
int commitable;
int workdir_dirty;
int workdir_untracked;
+ const char *index_file;
+ FILE *fp;
};
int git_status_config(const char *var, const char *value);
--
1.5.2.2
^ permalink raw reply related
* Re: why does git perpetually complain about include/asm-blackfin/macros.h?
From: Robert P. J. Day @ 2007-07-02 14:22 UTC (permalink / raw)
To: Jeff Garzik
Cc: Jesper Juhl, Linux Kernel Mailing List, Git Mailing List,
Linus Torvalds
In-Reply-To: <4689073D.1020802@garzik.org>
On Mon, 2 Jul 2007, Jeff Garzik wrote:
> Jesper Juhl wrote:
> > On 02/07/07, Jeff Garzik <jeff@garzik.org> wrote:
> > > Robert P. J. Day wrote:
> > > > for the umpteenth time, after doing a pull, i see this:
> > > >
> > > > $ git diff
> > > > diff --git a/include/asm-blackfin/macros.h
> > > b/include/asm-blackfin/macros.h
> > > > deleted file mode 100644
> > > > index e69de29..0000000
> > > > $
> > >
> > > I have the same problem. git 1.5.0.6 on Fedora Core 5 or 6.
> > >
> > > I even tried a completely fresh clone, but the problem still appears.
> > >
> > I've seen that as well, but in my case doing a
> > $ git reset --hard master
> > fixed it.
>
> Sure. git checkout -f fixes it too.
>
> But then it reappears the every time I switch branches.
same here -- checkout fixes it, but back it comes after the next pull.
not fatal -- just annoying.
rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================
^ permalink raw reply
* Re: why does git perpetually complain about include/asm-blackfin/macros.h?
From: Marco Roeland @ 2007-07-02 14:24 UTC (permalink / raw)
To: Jesper Juhl
Cc: Jeff Garzik, Robert P. J. Day, Linux Kernel Mailing List,
Git Mailing List, Linus Torvalds
In-Reply-To: <9a8748490707020658t5e6542ag6edb435dbc4499ab@mail.gmail.com>
On Monday July 2nd 2007 at 15:58 Jesper Juhl wrote:
> [obnoxious zero sized file include/asm-blackfin/macros.h that gets
> zapped by toolchains and resurrected again by git]
>
> I've seen that as well, but in my case doing a
> $ git reset --hard master
> fixed it.
Dangerous, as it may overwrite local changes you have! A simple "git
checkout include/asm-blackfin/macros.h" is much safer in this case.
In git commit df30b11 this file got redundant. Perhaps because a normal
patch was applied, instead of with git, the file didn't get deleted from
the repository but truncated to size zero. Not strictly wrong perse, but
for the Linux repository highly unusual (and the only one at that).
Your toolchain perhaps deletes files with zero size after cleaning up or
something. Git then notices that you deleted this file.
Perhaps someone can apply something like the following to finally fix
this up:
commit 7d98740800f3d9ad2428afa8c677be9573a51b7b
Author: Marco Roeland <marco.roeland@xs4all.nl>
Date: Mon Jul 2 16:19:49 2007 +0200
Blackfin arch: remove zero-sized include/asm-blackfin/macros.h
This file accidentally got truncated instead of deleted in commit df30b11.
Signed-off-by: Marco Roeland <marco.roeland@xs4all.nl>
diff --git a/include/asm-blackfin/macros.h b/include/asm-blackfin/macros.h
deleted file mode 100644
index e69de29..0000000
^ permalink raw reply
* Re: why does git perpetually complain about include/asm-blackfin/macros.h?
From: Alex Riesen @ 2007-07-02 14:25 UTC (permalink / raw)
To: Jeff Garzik
Cc: Jesper Juhl, Robert P. J. Day, Linux Kernel Mailing List,
Git Mailing List, Linus Torvalds
In-Reply-To: <81b0412b0707020722q25e8eb41t456e7316fe4a7b40@mail.gmail.com>
On 7/2/07, Alex Riesen <raa.lkml@gmail.com> wrote:
> In that second case I can only suspect that all your branches point
> at the same commit, which is just before the one the file was removed
> in...
_Not_ the same. Just some commit before the file was removed, of course.
^ permalink raw reply
* Re: why does git perpetually complain about include/asm-blackfin/macros.h?
From: Marco Roeland @ 2007-07-02 14:29 UTC (permalink / raw)
To: Alex Riesen
Cc: Jeff Garzik, Jesper Juhl, Robert P. J. Day,
Linux Kernel Mailing List, Git Mailing List, Linus Torvalds
In-Reply-To: <81b0412b0707020722q25e8eb41t456e7316fe4a7b40@mail.gmail.com>
On Monday July 2nd 2007 at 16:22 Alex Riesen wrote:
> Do some of your branches miss the commit by which it was removed?
> (It was removed in df30b1171714bbf0e55ffe02138be4b8447e4235)
> Than it will reappear every time you switch to a branch which still has
> the file.
The problem is that this commit didn't delete the file, but truncated it
to zero size. How it got to be like that is another matter. Within the
kernel zero sized files are not supposed to be there, by widely accepted
practice. So lots of tools assume they should delete them!
--
Marco Roeland
^ permalink raw reply
* Re: why does git perpetually complain about include/asm-blackfin/macros.h?
From: Jeff Garzik @ 2007-07-02 14:37 UTC (permalink / raw)
To: Alex Riesen
Cc: Jesper Juhl, Robert P. J. Day, Linux Kernel Mailing List,
Git Mailing List, Linus Torvalds, Sam Ravnborg
In-Reply-To: <81b0412b0707020722q25e8eb41t456e7316fe4a7b40@mail.gmail.com>
Alex Riesen wrote:
> Do some of your branches miss the commit by which it was removed?
git-clone followed by git-checkout master recreates the problem.
But to answer your question directly, I rebase, so they absolutely do
not miss any commits.
> It is somewhat unclear what "reappear" means, though: do you mean
Attempts to give you precise output to answer your question yielded a
data point, the kernel's "make distclean" causes this:
[jgarzik@pretzel linux-2.6]$ make distclean && git checkout master &&
git diff HEAD
D include/asm-blackfin/macros.h
Switched to branch "master"
diff --git a/include/asm-blackfin/macros.h b/include/asm-blackfin/macros.h
deleted file mode 100644
index e69de29..0000000
[jgarzik@pretzel linux-2.6]$ git checkout -f
[jgarzik@pretzel linux-2.6]$ make distclean && git checkout master &&
git diff HEAD
D include/asm-blackfin/macros.h
Switched to branch "master"
diff --git a/include/asm-blackfin/macros.h b/include/asm-blackfin/macros.h
deleted file mode 100644
index e69de29..0000000
[jgarzik@pretzel linux-2.6]$ git checkout -f
[jgarzik@pretzel linux-2.6]$ git checkout master && git diff
HEADSwitched to branch "master"
[jgarzik@pretzel linux-2.6]$ git checkout master && git diff HEAD
Switched to branch "master"
[jgarzik@pretzel linux-2.6]$
So, not a git problem but a kernel Makefile problem. Sorry for the git
noise.
Jeff
^ permalink raw reply
* Re: [PATCH] git-mergetool: add support for ediff
From: Theodore Tso @ 2007-07-02 14:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jason Sewall, Sam Vilain, git
In-Reply-To: <7vr6nrz9yx.fsf@assigned-by-dhcp.cox.net>
On Sun, Jul 01, 2007 at 09:49:10PM -0700, Junio C Hamano wrote:
> The reason I personally use emacsclient is not about the
> start-up delay, but with the access to existing buffers,
> keyboard macros, Gnus buffers, ... IOW the access to the
> "session" while editing. I suspect people with long running
> Emacs session use emacsclient for that reason.
Sure, but do you need access to existing buffers, keyboard, macros,
etc., if you're simply firing up an emacs to handle a merge conflict?
If the goal is just to run a merge application, then firing up a
separate process makes a lot more sense.
One other thing which I just noticed is that emacs21's emacsclient
does NOT support the -f or -e option. And a lot of people may still
be using emacs21. So in any case, at the moment we are in fact using
to fire up a separate process when using emerge or ediff. I suppose
we could try testing to see if the user is running emacs21 or emacs22
if EDITOR==emacsclient, but there's no easy way of doing this short of
doing something heavyweight such as firing up emacs and asking to eval
some lisp that prints the value of emacs-version to stdout. And even
then we would have to fix emerge to do the right thing when invoked
via emacsclient. Yuck...
This still leaves us with the question about whether the following to
fix ediff is acceptable:
emacs --eval "(progn (defun ediff-write-merge-buffer () (let ((file ediff-merge-store-file)) (set-buffer ediff-buffer-C) (write-region (point-min) (point-max) file) (message \"Merge buffer saved in: %s\" file) (set-buffer-modified-p nil) (sit-for 1))) (setq ediff-quit-hook 'kill-emacs ediff-quit-merge-hook 'ediff-write-merge-buffer) (ediff-merge-files-with-ancestor \"$LOCAL\" \"$REMOTE\" \"$BASE\" nil \"$path\"))"
In my mind it's on the hairy edge. Alternatively we just never use
ediff by default, and assume that either expert users can hack their
.emacs.el file to have the right overrides will use ediff, or who are
willing to put up with ediff's user-hostile approach to quitting an
merge session.
- Ted
^ permalink raw reply
* Re: [PATCH] Make '!' aliases more useful
From: Theodore Tso @ 2007-07-02 14:55 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git, gitster
In-Reply-To: <Pine.LNX.4.64.0707012249590.4438@racer.site>
On Sun, Jul 01, 2007 at 10:51:58PM +0100, Johannes Schindelin wrote:
>
> When an alias starts with an exclamation mark, the rest is interpreted
> as a shell command. However, all arguments passed to git used to be
> ignored.
>
> Now you can have an alias like
>
> $ git config alias.e '!echo'
>
> and
>
> $ git e Hello World
>
> does what you expect it to do.
But what if you don't want the argument passed at the end of the
alias, but somewhere else? I suspect the better answer would be to
support $* and $1, $2, $3, et. al interpolation, no? It was on my
list of things to do when I had a spare moment, but I never got around
to it.
- Ted
^ permalink raw reply
* [PATCH] Blackfin arch: include/asm-blackfin/macros.h die die die
From: Marco Roeland @ 2007-07-02 15:09 UTC (permalink / raw)
To: Alex Riesen
Cc: Jeff Garzik, Jesper Juhl, Robert P. J. Day,
Linux Kernel Mailing List, Git Mailing List, Linus Torvalds
In-Reply-To: <20070702142926.GB10400@fiberbit.xs4all.nl>
This file accidentally got truncated instead of deleted in commit df30b11.
Doing a "make distclean" or "make mrproper" deletes this file because of
its zero size. Git then sees this as an uncommitted local change.
Signed-off-by: Marco Roeland <marco.roeland@xs4all.nl>
---
0 files changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 include/asm-blackfin/macros.h
diff --git a/include/asm-blackfin/macros.h b/include/asm-blackfin/macros.h
deleted file mode 100644
index e69de29..0000000
--
1.5.2.2.1451.gb0e5e
^ permalink raw reply
* Re: why does git perpetually complain about include/asm-blackfin/macros.h?
From: Linus Torvalds @ 2007-07-02 15:36 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Robert P. J. Day, Linux Kernel Mailing List, Git Mailing List
In-Reply-To: <4688EF9B.8020405@garzik.org>
On Mon, 2 Jul 2007, Jeff Garzik wrote:
> Robert P. J. Day wrote:
> > for the umpteenth time, after doing a pull, i see this:
> >
> > $ git diff
> > diff --git a/include/asm-blackfin/macros.h b/include/asm-blackfin/macros.h
> > deleted file mode 100644
> > index e69de29..0000000
> > $
>
> I have the same problem. git 1.5.0.6 on Fedora Core 5 or 6.
>
> I even tried a completely fresh clone, but the problem still appears.
Git complains for a very simple reason: that file is an empty file, and
"make clean" removes all zero-sized files.
So whenever anybody does a "make clean" (maybe it's "make distclean", I
forget), you will have removed the empty file, and git will show it as a
diff.
We probably should just remove the file from the kernel archive.
Linus
^ permalink raw reply
* RE: [PATCH] git-submodule: Try harder to describe the status of a submodule
From: Medve Emilian-EMMEDVE1 @ 2007-07-02 15:44 UTC (permalink / raw)
To: git
In-Reply-To: <598D5675D34BE349929AF5EDE9B03E27011CFFED@az33exm24.fsl.freescale.net>
Hello Junio,
I noticed the 1.5.2.3 tag and the plans for 1.5.3-rc1 and I was
wondering when do you think you'll apply your submodule patch? Is there
any way I can help with it?
Thanks,
Emil.
This e-mail, and any associated attachments have been classified as:
--------------------------------------------------------------------
[x] Public
[ ] Freescale Semiconductor Internal Use Only
[ ] Freescale Semiconductor Confidential Proprietary
-----Original Message-----
From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On
Behalf Of Medve Emilian-EMMEDVE1
Sent: Thursday, June 28, 2007 8:01 AM
To: git@vger.kernel.org
Subject: RE: [PATCH] git-submodule: Try harder to describe the status of
a submodule
Hello Junio,
Alright, let's go with your patch.
Cheers,
Emil.
This e-mail, and any associated attachments have been classified as:
--------------------------------------------------------------------
[x] Public
[ ] Freescale Semiconductor Internal Use Only
[ ] Freescale Semiconductor Confidential Proprietary
-----Original Message-----
From: Junio C Hamano [mailto:gitster@pobox.com]
Sent: Wednesday, June 27, 2007 11:25 PM
To: Medve Emilian-EMMEDVE1
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-submodule: Try harder to describe the status of
a submodule
Emil Medve <Emilian.Medve@Freescale.com> writes:
> Some repositories might not use/have annotated tags (for example
repositories created with
> git-cvsimport) or might not have tags at all and could cause
git-submodule status to fail because
> git-describe might fail.
>
> This change makes git-submodule status try harder in displaying the
status of a module by
> considering lightweight tags, subsequent tags and branches.
Why are we suddenly seeing these loooooooong lines...
> +get_revname()
> +{
> + _revname=$(git-describe --tags "$1" 2>/dev/null || git-describe
--contains "$1" 2>/dev/null)
> + if test -z "$_revname" -o "$_revname" = "undefined"
> + then
> + _revname=$(git-describe --all "$1" 2>/dev/null | cut -d
/ -f2-)
> + test -z "$_revname" && _revname=undefined
> + fi
I really do not think using --all is useful. If you do not have
a tag and the rev cannot be described, what damage does it incur?
We still say "$sha1 $path" in the output anyway, and ($revname)
is only "it makes it nicer" appendix.
> @@ -155,7 +174,7 @@ modules_list()
> say "-$sha1 $path"
> continue;
> fi
> - revname=$(unset GIT_DIR && cd "$path" && git-describe
$sha1)
> + revname=$(unset GIT_DIR && cd "$path" && get_revname
$sha1)
> if git diff-files --quiet -- "$path"
> then
> say " $sha1 $path ($revname)"
In that sense, I would prefer mine much better. If a rev is
indescribable, your version would say:
" dddddddddddddddddddddddddddddddddddddddd subdir (undefined)"
while mine would have said:
" dddddddddddddddddddddddddddddddddddddddd subdir"
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox