* Re: [PATCH v2 1/3] t7700: demonstrate mishandling of objects in packs with a .keep file
From: Brandon Casey @ 2008-11-04 20:01 UTC (permalink / raw)
To: Junio C Hamano
Cc: Andreas Ericsson, Shawn O. Pearce, Git Mailing List,
Nicolas Pitre
In-Reply-To: <7vmygfqn92.fsf@gitster.siamese.dyndns.org>
Junio C Hamano wrote:
> Brandon Casey <casey@nrlssc.navy.mil> writes:
>> sed -n -e '$q' -e 'p'
>
> You surely meant "sed -e '$d'", right?
Your sed-fu is quite impressive.
-b
^ permalink raw reply
* Re: [PATCH v2 1/3] t7700: demonstrate mishandling of objects in packs with a .keep file
From: Junio C Hamano @ 2008-11-04 19:55 UTC (permalink / raw)
To: Brandon Casey
Cc: Andreas Ericsson, Shawn O. Pearce, Git Mailing List,
Nicolas Pitre
In-Reply-To: <V78jOMhdYwpSlLU-YzsqEHZxJyrvKbXRQbKsuNPZOEtB8E0kZ5Wi7Q@cipher.nrlssc.navy.mil>
Brandon Casey <casey@nrlssc.navy.mil> writes:
> Andreas Ericsson wrote:
>
>> sed 1q is faster, as it stops parsing after the first line (the same as
>> 'head
>> -n 1' does, but in a more portable fashion).
If your sed is GNU, and you are doing this for a small file, the startup
cost of it may dwarf such gain ;-)
> Except that I wanted all but the _last_ line though.
>
> I didn't think about using sed. Perhaps I could have used something like
>
> sed -n -e '$q' -e 'p'
You surely meant "sed -e '$d'", right?
> The grep works though.
Indeed.
^ permalink raw reply
* Re: [PATCH v2 1/3] t7700: demonstrate mishandling of objects in packs with a .keep file
From: Brandon Casey @ 2008-11-04 19:49 UTC (permalink / raw)
To: Andreas Ericsson
Cc: Junio C Hamano, Shawn O. Pearce, Git Mailing List, Nicolas Pitre
In-Reply-To: <49109FD4.30003@op5.se>
Andreas Ericsson wrote:
> Brandon Casey wrote:
>> From: Brandon Casey <drafnel@gmail.com>
>>
>> Objects residing in pack files that have an associated .keep file are not
>> supposed to be repacked into new pack files, but they are.
>>
>> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
>> ---
>>
>>
>> This version replaces the use of 'head -n -1' with a grep, and should
>> work on
>> all platforms.
>>
>
> sed 1q is faster, as it stops parsing after the first line (the same as
> 'head
> -n 1' does, but in a more portable fashion).
Except that I wanted all but the _last_ line though.
I didn't think about using sed. Perhaps I could have used something like
sed -n -e '$q' -e 'p'
The grep works though.
-brandon
^ permalink raw reply
* Re: [PATCH] Documentation: add a planning document for the next CLI revamp
From: Junio C Hamano @ 2008-11-04 19:46 UTC (permalink / raw)
To: Sam Vilain
Cc: Dmitry Potapov, Jeff King, Sam Vilain, git, Johannes Schindelin,
Scott Chacon, Tom Preston-Werner, J.H., Christian Couder,
Kai Blin
In-Reply-To: <1225822231.6722.3.camel@maia.lan>
Sam Vilain <sam@vilain.net> writes:
> On Tue, 2008-11-04 at 12:18 +0300, Dmitry Potapov wrote:
> ...
>> The only one who does publishing to the official repository
>> is the maintainer, and the maintainer is most likely to run some tests
>> after merging all changes, which takes some time. So, it is rarely push
>> the current branch, it is usually the branch that has been tested, so
>> the name of the branch should be specified explicitly anyway.
>
> Why is that relevant? That person can still use the explicit version of
> the command.
Back when "git push $there :" were not available, the default matching
behaviour was the _only_ way to say "I know the set of branches I want to
publish, and I have many more private branches in my primary work
repository. I do not want to list the set of branches to publish every
time when I type 'git push', nor I want to configure it --- Heck, I
shouldn't have to list them, the public repository I am pushing to already
has that list, and it is the set of branches that exist there".
These days, people who would want the maching behaviour can explicitly ask
for it, so there is one less reason to resist changing the default
(i.e. earlier explicitly askinf for "matching" was impossible, but now we
can). The remaining reason of resistance is pure inertia (i.e. not
changing the behaviour of the command only because you upgraded your git),
and the only way to address it is to start issuing the warning when "git
push" or "git push $there" is used and the matching behaviour was chosen
without configuration (i.e. no "remote.<there>.push = :"), and keep it
that way for two release cycles, and finally change the default.
^ permalink raw reply
* Re: [PATCH] t7700: demonstrate mishandling of objects in packs with a .keep file
From: Andreas Ericsson @ 2008-11-04 19:25 UTC (permalink / raw)
To: Brandon Casey; +Cc: drafnel, git, gitster, nico
In-Reply-To: <76IhmMdjmr4jA4xApPpvlZ4vfjtqEDsUaFal2mN5MHfI0MChFmsj5g@cipher.nrlssc.navy.mil>
Brandon Casey wrote:
> Andreas Ericsson wrote:
>
>> So long as "git repack -a" still creates a mega-pack, I'm fine with
>> whatever.
>
> I don't think it will after pack-objects is taught about .keep files, and
In that case you're almost certainly breaking something.
> I don't think it will _now_ if all of your packs have .keep files.
>
It should, by copying the objects from the .keep-marked packfiles. Otherwise
either repack or the repack docs are in error.
> 'repack -a' will call pack-objects with either '--unpack=<packfile>' for
> each pack file without a .keep file, or with '--unpacked --incremental' if
> there are no pack files without .keep files.
>
> In the first case, the modifications to pack-objects that I propose
> will prevent objects that exist in local packs with .keep files
> from being packed into the new pack.
>
> In the second case, the --incremental option would have done the same thing.
>
> So this inconsistency already existed, but will now be removed in favor of
> honoring .keep files.
>
That means the nifty hack of incrementally and sometimes fully repack the
odb to speed up cloning over dumb protocols no longer works properly, then.
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
^ permalink raw reply
* Re: [PATCH v2 1/3] t7700: demonstrate mishandling of objects in packs with a .keep file
From: Andreas Ericsson @ 2008-11-04 19:17 UTC (permalink / raw)
To: Brandon Casey
Cc: Junio C Hamano, Shawn O. Pearce, Git Mailing List, Nicolas Pitre
In-Reply-To: <muOuA1nLBoljLnZoguxeFeKt-8Q-I9Y3ljvxnLWLt9KyA8HwVtMa4Q@cipher.nrlssc.navy.mil>
Brandon Casey wrote:
> From: Brandon Casey <drafnel@gmail.com>
>
> Objects residing in pack files that have an associated .keep file are not
> supposed to be repacked into new pack files, but they are.
>
> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
> ---
>
>
> This version replaces the use of 'head -n -1' with a grep, and should work on
> all platforms.
>
sed 1q is faster, as it stops parsing after the first line (the same as 'head
-n 1' does, but in a more portable fashion).
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
^ permalink raw reply
* Re: [PATCH] Documentation: add a planning document for the next CLI revamp
From: Sam Vilain @ 2008-11-04 18:10 UTC (permalink / raw)
To: Dmitry Potapov
Cc: Junio C Hamano, Jeff King, Sam Vilain, git, Johannes Schindelin,
Scott Chacon, Tom Preston-Werner, J.H., Christian Couder,
Kai Blin
In-Reply-To: <20081104091800.GB24100@dpotapov.dyndns.org>
On Tue, 2008-11-04 at 12:18 +0300, Dmitry Potapov wrote:
> > I can see that some people want this behaviour by default; but to me
> > "push the current branch back to where it came from" seems like far more
> > a rational default for at least 90% of users.
>
> I think it depends on one's workflow. If you use a centralized workflow
> as with CVS then yes, 90% cases you want to push the current branch. On
> the other hand, if people push their changes to the server only for
> review, it means that accidentally pushing more than one intended is not
> a big deal.
Perhaps not, but it was still unintended. I really can't understand the
opposition to making this command make many people less angry at it.
> The only one who does publishing to the official repository
> is the maintainer, and the maintainer is most likely to run some tests
> after merging all changes, which takes some time. So, it is rarely push
> the current branch, it is usually the branch that has been tested, so
> the name of the branch should be specified explicitly anyway.
Why is that relevant? That person can still use the explicit version of
the command.
Sam.
^ permalink raw reply
* [PATCH 3/3 v2] Documentation: add "git bisect replace" documentation
From: Christian Couder @ 2008-11-04 17:35 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
Documentation/git-bisect.txt | 63 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
index c7981ef..3cb98b9 100644
--- a/Documentation/git-bisect.txt
+++ b/Documentation/git-bisect.txt
@@ -24,6 +24,7 @@ on the subcommand:
git bisect visualize
git bisect replay <logfile>
git bisect log
+ git bisect replace <rev> [<rev>]
git bisect run <cmd>...
This command uses 'git-rev-list --bisect' to help drive the
@@ -186,6 +187,68 @@ $ git bisect start v2.6.20-rc6 v2.6.20-rc4 v2.6.20-rc1 --
# v2.6.20-rc4 and v2.6.20-rc1 are good
------------
+Bisect replace
+~~~~~~~~~~~~~~
+
+This subcommand should be used when you have a branch or a part of a
+branch that isn't easily bisectable because of a bug that has been
+fixed latter.
+
+We suppose that a bug as been introduced at some point, say A, and
+that it has been fixed latter at another point, say B, but that
+between these points the code is not easily testable because of the
+bug, so it's not easy to bisect between these points.
+
+In this case you can create a branch starting at the parent of A, say
+O, that has a fixed history. In this fixed history for example, there
+could be first a commit C that is the result of squashing A and B
+together and then all the commits between A and B that have been cherry
+picked.
+
+For example, let's say the commits between A and B are X1, X2, ... Xn
+and they have been cherry picked after C as Y1, Y2, ... Yn:
+
+------------
+ C--Y1--Y2--...--Yn
+ /
+...--O--A--X1--X2--...--Xn--B--...
+------------
+
+By design, the last cherry picked commit (Yn) should point to the same
+tree as commit B.
+
+So in this case you can say:
+
+------------
+$ git bisect replace B Yn
+------------
+
+and commit B will be tagged with a special name like:
+"bisect-replace-with-Yn"
+
+(A branch that points to commit Yn will also be created with a name
+like: "bisect-replace-B")
+
+When bisecting, each commit with one of those tags will be grafted so
+that its parents will be replaced by the commit specified in the tag.
+
+In the example above, that means that instead of the above graph, the
+following graph will be bisected:
+
+------------
+ C--Y1--Y2--...--Yn
+ / \
+...--O B--...
+------------
+
+This means that the bisections on this branch may be much easier
+because the bug introduced by commit A and fixed by commit B will not
+annoy you anymore.
+
+As the branches and tags created by "git bisect replace" can be shared
+between developers, this feature might be especially usefull on big
+projects where many people often bisect the same code base.
+
Bisect run
~~~~~~~~~~
--
1.6.0.3.528.gad674
^ permalink raw reply related
* [PATCH 2/3 v2] bisect: add test cases for "git bisect replace"
From: Christian Couder @ 2008-11-04 17:35 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
t/t6035-bisect-replace.sh | 114 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 114 insertions(+), 0 deletions(-)
create mode 100755 t/t6035-bisect-replace.sh
diff --git a/t/t6035-bisect-replace.sh b/t/t6035-bisect-replace.sh
new file mode 100755
index 0000000..e07cc10
--- /dev/null
+++ b/t/t6035-bisect-replace.sh
@@ -0,0 +1,114 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Christian Couder
+#
+test_description='Test git bisect replace functionality'
+
+exec </dev/null
+
+. ./test-lib.sh
+
+add_and_commit_file()
+{
+ _file="$1"
+ _msg="$2"
+
+ git add $_file || return $?
+ test_tick || return $?
+ git commit --quiet -m "$_file: $_msg"
+}
+
+HASH1=
+HASH2=
+HASH3=
+HASH4=
+HASH5=
+HASH6=
+
+test_expect_success 'set up buggy branch' '
+ echo "line 1" >> hello &&
+ echo "line 2" >> hello &&
+ echo "line 3" >> hello &&
+ echo "line 4" >> hello &&
+ add_and_commit_file hello "4 lines" &&
+ HASH1=$(git rev-parse --verify HEAD) &&
+ echo "line BUG" >> hello &&
+ echo "line 6" >> hello &&
+ echo "line 7" >> hello &&
+ echo "line 8" >> hello &&
+ add_and_commit_file hello "4 more lines with a BUG" &&
+ HASH2=$(git rev-parse --verify HEAD) &&
+ echo "line 9" >> hello &&
+ echo "line 10" >> hello &&
+ add_and_commit_file hello "2 more lines" &&
+ HASH3=$(git rev-parse --verify HEAD) &&
+ echo "line 11" >> hello &&
+ add_and_commit_file hello "1 more line" &&
+ HASH4=$(git rev-parse --verify HEAD) &&
+ sed -e "s/BUG/5/" hello > hello.new &&
+ mv hello.new hello &&
+ add_and_commit_file hello "BUG fixed" &&
+ HASH5=$(git rev-parse --verify HEAD) &&
+ echo "line 12" >> hello &&
+ echo "line 13" >> hello &&
+ add_and_commit_file hello "2 more lines" &&
+ HASH6=$(git rev-parse --verify HEAD)
+'
+
+HASHFIX2=
+HASHFIX3=
+HASHFIX4=
+
+test_expect_success 'set up fixed branch' '
+ git checkout $HASH1 &&
+ echo "line 5" >> hello &&
+ echo "line 6" >> hello &&
+ echo "line 7" >> hello &&
+ echo "line 8" >> hello &&
+ add_and_commit_file hello "4 more lines with no BUG" &&
+ HASHFIX2=$(git rev-parse --verify HEAD) &&
+ git cherry-pick $HASH3 &&
+ HASHFIX3=$(git rev-parse --verify HEAD) &&
+ git cherry-pick $HASH4 &&
+ HASHFIX4=$(git rev-parse --verify HEAD)
+'
+
+test_expect_success '"git bisect replace" buggy branch with fixed one' '
+ git bisect replace $HASH5 HEAD
+'
+
+test_expect_success 'replace works when bisecting with a later bad commit' '
+ git rev-list --bisect-all $HASH6 > rev_list.txt &&
+ grep $HASHFIX2 rev_list.txt &&
+ grep $HASHFIX3 rev_list.txt &&
+ grep $HASHFIX4 rev_list.txt &&
+ test_must_fail grep $HASH2 rev_list.txt &&
+ test_must_fail grep $HASH3 rev_list.txt &&
+ test_must_fail grep $HASH4 rev_list.txt
+'
+
+test_expect_success 'replace works starting from replaced commit' '
+ git rev-list --bisect-all $HASH5 > rev_list.txt &&
+ grep $HASHFIX2 rev_list.txt &&
+ grep $HASHFIX3 rev_list.txt &&
+ grep $HASHFIX4 rev_list.txt &&
+ test_must_fail grep $HASH2 rev_list.txt &&
+ test_must_fail grep $HASH3 rev_list.txt &&
+ test_must_fail grep $HASH4 rev_list.txt
+'
+
+test_expect_success 'standard bisect works' '
+ git bisect start $HASH6 $HASH1 &&
+ test "$(git rev-parse --verify HEAD)" = "$HASHFIX3" &&
+ git bisect good &&
+ test "$(git rev-parse --verify HEAD)" = "$HASH5" &&
+ git bisect bad &&
+ test "$(git rev-parse --verify HEAD)" = "$HASHFIX4" &&
+ git bisect bad > my_bisect_log.txt &&
+ grep "$HASHFIX4 is first bad commit" my_bisect_log.txt &&
+ git bisect reset
+'
+
+#
+#
+test_done
--
1.6.0.3.528.gad674
^ permalink raw reply related
* [PATCH 1/3 v2] bisect: add "git bisect replace" subcommand
From: Christian Couder @ 2008-11-04 17:35 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
This subcommand should be used when you have a branch or a part of a
branch that isn't easily bisectable because of a bug that has been
fixed latter.
We suppose that a bug as been introduced at some point, say A, and
that it has been fixed latter at another point, say B, but that
between these points the code is not easily testable because of the
bug, so it's not easy to bisect between these points.
In this case you can create a branch starting at the parent of A, say
O, that has a fixed history. In this fixed history for example, there
could be first a commit C that is the result of squashing A and B
together and then all the commits between A and B that have been
cherry picked.
For example, let's say the commits between A and B are X1, X2, ... Xn
and they have been cherry picked after C as Y1, Y2, ... Yn:
C--Y1--Y2--...--Yn
/
...--O--A--X1--X2--...--Xn--B--...
By design, the last cherry picked commit (Yn) should point to the same
tree as commit B.
So in this case you can say:
$ git bisect replace B Yn
and commit B will be tagged with a special name like:
"bisect-replace-with-Yn"
(A branch that points to commit Yn will also be created with a name
like: "bisect-replace-B")
When bisecting, each commit with one of those tags will be grafted so
that its parents will be replaced by the commit specified in the tag.
In the example above that means that instead of the above graph, the
following graph will be bisected:
C--Y1--Y2--...--Yn
/ \
...--O B--...
This means that the bisections on this branch will be much easier
because the bug introduced by commit A and fixed by commit B will not
annoy you anymore.
As the branches and tags created by "git bisect replace" can be shared
between developers, this feature might be especially usefull on big
projects where many people often bisect the same code base.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
builtin-rev-list.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++-
git-bisect.sh | 40 +++++++++++++++++++++++-
2 files changed, 125 insertions(+), 2 deletions(-)
Changes since previous series are the following:
- replace parents of a commit that has already been created
when bisect_replace() is called (1/1)
- check that the new parent of a commit exists before using it
to replace existing parents (1/1)
- improve tests (2/3)
- add a documentation patch (3/3)
Thank you Junio for your help in designing this during the GitTogether,
especially for the trick to change the parents of the commit fixing the
bug.
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 06cdeb7..f29c548 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -529,6 +529,88 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
return best_bisection_sorted(list, nr);
}
+static struct commit *check_replace_parents(unsigned char *parent,
+ const char *refname,
+ const unsigned char *sha1)
+{
+ struct commit *new_parent;
+ if (get_sha1_hex(refname + 20, parent)) {
+ warning("bad sha1 in tag name '%s'", refname);
+ return NULL;
+ }
+ new_parent = lookup_commit(parent);
+ if (!new_parent) {
+ warning("tag name '%s' refers to an unknown commit\n"
+ "Please make sure you have the branch "
+ "'bisect-replace-%s'.\n"
+ "Or delete tag '%s'.",
+ refname, sha1_to_hex(sha1), refname);
+ return NULL;
+ }
+ return new_parent;
+}
+
+static void replace_parents(struct commit *commit,
+ const char *refname,
+ const unsigned char *sha1)
+{
+ unsigned char parent[20];
+ struct commit *new_parent;
+
+ new_parent = check_replace_parents(parent, refname, sha1);
+
+ if (new_parent) {
+ free_commit_list(commit->parents);
+ commit->parents = NULL;
+ commit_list_insert(new_parent, &commit->parents);
+ }
+}
+
+static int bisect_replace(const char *refname, const unsigned char *sha1,
+ int flag, void *cb_data)
+{
+ struct object *obj;
+ struct commit_graft *graft;
+ struct commit *new_parent;
+
+ if (prefixcmp(refname, "bisect-replace-with-"))
+ return 0;
+
+ /* See if we already have the commit */
+
+ obj = lookup_object(sha1);
+ if (obj) {
+ struct commit *commit;
+ if (obj->type != OBJ_COMMIT)
+ return 0;
+ commit = (struct commit *) obj;
+ if (commit->object.parsed) {
+ replace_parents(commit, refname, sha1);
+ return 0;
+ }
+ }
+
+ /* Create a graft to replace current commit */
+
+ graft = xmalloc(sizeof(*graft) + 20);
+
+ hashcpy(graft->sha1, sha1);
+ graft->nr_parent = 1;
+
+ /*
+ * We create commits that we may not need
+ * and cannot easily free, but at least it is safe.
+ */
+ new_parent = check_replace_parents(graft->parent[0], refname, sha1);
+
+ if (new_parent)
+ register_commit_graft(graft, 1);
+ else
+ free(graft);
+
+ return 0;
+}
+
static struct commit_list *find_bisection(struct commit_list *list,
int *reaches, int *all,
int find_all)
@@ -646,8 +728,11 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
save_commit_buffer = revs.verbose_header ||
revs.grep_filter.pattern_list;
- if (bisect_list)
+
+ if (bisect_list) {
+ for_each_tag_ref(bisect_replace, NULL);
revs.limited = 1;
+ }
if (prepare_revision_walk(&revs))
die("revision walk setup failed");
diff --git a/git-bisect.sh b/git-bisect.sh
index 0d0e278..245435c 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-USAGE='[help|start|bad|good|skip|next|reset|visualize|replay|log|run]'
+USAGE='[help|start|bad|good|skip|next|reset|visualize|replay|log|run|replace]'
LONG_USAGE='git bisect help
print this long help message.
git bisect start [<bad> [<good>...]] [--] [<pathspec>...]
@@ -23,6 +23,8 @@ git bisect log
show bisect log.
git bisect run <cmd>...
use <cmd>... to automatically bisect.
+git bisect replace <rev> [<rev>]
+ use another branch for bisection.
Please use "git help bisect" to get the full man page.'
@@ -618,6 +620,40 @@ bisect_run () {
done
}
+bisect_replace() {
+ test "$#" -ge 1 -a "$#" -le 2 ||
+ die "'git bisect replace' accept one or two arguments"
+
+ source="$1"
+ target="${2:-HEAD}"
+
+ # Check arguments
+ src_commit=$(git rev-parse --verify "$source^{commit}") ||
+ die "Bad rev input: $source"
+ tgt_commit=$(git rev-parse --verify "$target^{commit}") ||
+ die "Bad rev input: $target"
+
+ test "$src_commit" != "tgt_commit" ||
+ die "source and target should be different commits"
+
+ # Check that trees from source and target are identical
+ src_tree=$(git rev-parse --verify "$src_commit^{tree}") ||
+ die "Could not get tree for source: $source"
+ tgt_tree=$(git rev-parse --verify "$tgt_commit^{tree}") ||
+ die "Could not get tree for target: $target"
+
+ test "$src_tree" = "$tgt_tree" ||
+ die "source and target should point to the same tree"
+
+ # Tag the source commit
+ src_tag="bisect-replace-with-$tgt_commit"
+ git tag "$src_tag" "$src_commit" || exit
+
+ # Create branch for the target commit
+ tgt_branch="bisect-replace-$src_commit"
+ git branch "$tgt_branch" "$tgt_commit" || exit
+}
+
case "$#" in
0)
@@ -645,6 +681,8 @@ case "$#" in
cat "$GIT_DIR/BISECT_LOG" ;;
run)
bisect_run "$@" ;;
+ replace)
+ bisect_replace "$@" ;;
*)
usage ;;
esac
--
1.6.0.3.528.gad674
^ permalink raw reply related
* [PATCH] Add git-gui--askpass to git.spec.in
From: Yutaka Kanemoto @ 2008-11-04 17:15 UTC (permalink / raw)
To: git, gitster
'make rpm' will fail because git-gui--askpass is not listed in git.spec.in.
At least, I was able to create rpm using below patch.
Best regards,
Yutaka KANEMOTO
---
git.spec.in | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/git.spec.in b/git.spec.in
index 6733b6f..bf7fa63 100644
--- a/git.spec.in
+++ b/git.spec.in
@@ -167,6 +167,7 @@ rm -rf $RPM_BUILD_ROOT
%files gui
%defattr(-,root,root)
%{_libexecdir}/git-core/git-gui
+%{_libexecdir}/git-core/git-gui--askpass
%{_libexecdir}/git-core/git-citool
%{_datadir}/git-gui/
%{!?_without_docs: %{_mandir}/man1/git-gui.1*}
--
1.6.0.3.613.g9f8f13.dirty
^ permalink raw reply related
* [PATCH 5/5] git send-email: turn --compose on when more than one patch.
From: Pierre Habouzit @ 2008-11-04 16:24 UTC (permalink / raw)
To: git; +Cc: Pierre Habouzit
In-Reply-To: <1225815858-30617-5-git-send-email-madcoder@debian.org>
Automatically turn --compose on when there is more than one patch, and
that the output is a tty.
Do not print the list of files sent anymore in that case, as the list is
shown in the summary editor.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
git-send-email.perl | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index fd72127..3c7818f 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -51,7 +51,7 @@ git send-email [options] <file | directory | rev-list options >
--subject <str> * Email "Subject:"
--in-reply-to <str> * Email "In-Reply-To:"
--annotate * Review each patch that will be sent in an editor.
- --compose * Open an editor for introduction.
+ --[no-]compose * Open an editor for introduction.
Sending:
--envelope-sender <str> * Email envelope sender.
@@ -237,7 +237,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
"smtp-encryption=s" => \$smtp_encryption,
"identity=s" => \$identity,
"annotate" => \$annotate,
- "compose" => \$compose,
+ "compose!" => \$compose,
"quiet" => \$quiet,
"cc-cmd=s" => \$cc_cmd,
"suppress-from!" => \$suppress_from,
@@ -425,7 +425,11 @@ if ($validate) {
}
if (@files) {
- unless ($quiet) {
+ if (!defined($compose) && -t STDOUT) {
+ # turn $compose on if there is more than one file
+ $compose = $#files;
+ }
+ unless ($quiet || $compose) {
print $_,"\n" for (@files);
}
} else {
--
1.5.6.5
^ permalink raw reply related
* [PATCH 4/5] git send-email: ask less questions when --compose is used.
From: Pierre Habouzit @ 2008-11-04 16:24 UTC (permalink / raw)
To: git; +Cc: Pierre Habouzit
In-Reply-To: <1225815858-30617-4-git-send-email-madcoder@debian.org>
When --compose is used, we can grab the From/Subject/In-Reply-To from the
edited summary, let it be so and don't ask the user silly questions.
The summary templates gets quite revamped, and includes the list of
patches subjects that are going to be sent with this batch.
When having a body full of empty lines, the summary isn't sent. Document
that in the git-send-email manpage fully.
Note: It doesn't deal with To/Cc/Bcc yet.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
Documentation/git-send-email.txt | 9 ++
git-send-email.perl | 177 ++++++++++++++++++++++---------------
2 files changed, 114 insertions(+), 72 deletions(-)
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 39d6da9..e06db6b 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -45,6 +45,15 @@ The --cc option must be repeated for each user you want on the cc list.
--compose::
Use $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an
introductory message for the patch series.
++
+When compose is in used, git send-email gets less interactive will use the
+values of the headers you set there. If the body of the email (what you type
+after the headers and a blank line) only contains blank (or GIT: prefixed)
+lines, the summary won't be sent, but git-send-email will still use the
+Headers values if you don't removed them.
++
+If it wasn't able to see a header in the summary it will ask you about it
+interactively after quitting your editor.
--from::
Specify the sender of the emails. This will default to
diff --git a/git-send-email.perl b/git-send-email.perl
index d0c5a41..fd72127 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -433,6 +433,108 @@ if (@files) {
usage();
}
+sub get_patch_subject($) {
+ my $fn = shift;
+ open (my $fh, '<', $fn);
+ while (my $line = <$fh>) {
+ next unless ($line =~ /^Subject: (.*)$/);
+ close $fh;
+ return "GIT: $1\n";
+ }
+ close $fh;
+ die "No subject line in $fn ?";
+}
+
+if ($compose) {
+ # Note that this does not need to be secure, but we will make a small
+ # effort to have it be unique
+ open(C,">",$compose_filename)
+ or die "Failed to open for writing $compose_filename: $!";
+
+
+ my $tpl_sender = $sender || $repoauthor || $repocommitter || '';
+ my $tpl_subject = $initial_subject || '';
+ my $tpl_reply_to = $initial_reply_to || '';
+
+ print C <<EOT;
+From $tpl_sender # This line is ignored.
+GIT: Lines beginning in "GIT: " will be removed.
+GIT: Consider including an overall diffstat or table of contents
+GIT: for the patch you are writing.
+GIT:
+GIT: Clear the body content if you don't wish to send a summary.
+From: $tpl_sender
+Subject: $tpl_subject
+In-Reply-To: $tpl_reply_to
+
+EOT
+ for my $f (@files) {
+ print C get_patch_subject($f);
+ }
+ close(C);
+
+ my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
+
+ if ($annotate) {
+ do_edit($compose_filename, @files);
+ } else {
+ do_edit($compose_filename);
+ }
+
+ open(C2,">",$compose_filename . ".final")
+ or die "Failed to open $compose_filename.final : " . $!;
+
+ open(C,"<",$compose_filename)
+ or die "Failed to open $compose_filename : " . $!;
+
+ my $need_8bit_cte = file_has_nonascii($compose_filename);
+ my $in_body = 0;
+ my $summary_empty = 1;
+ while(<C>) {
+ next if m/^GIT: /;
+ if ($in_body) {
+ $summary_empty = 0 unless (/^\n$/);
+ } elsif (/^\n$/) {
+ $in_body = 1;
+ if ($need_8bit_cte) {
+ print C2 "MIME-Version: 1.0\n",
+ "Content-Type: text/plain; ",
+ "charset=utf-8\n",
+ "Content-Transfer-Encoding: 8bit\n";
+ }
+ } elsif (/^MIME-Version:/i) {
+ $need_8bit_cte = 0;
+ } elsif (/^Subject:\s*(.+)\s*$/i) {
+ $initial_subject = $1;
+ my $subject = $initial_subject;
+ $_ = "Subject: " .
+ ($subject =~ /[^[:ascii:]]/ ?
+ quote_rfc2047($subject) :
+ $subject) .
+ "\n";
+ } elsif (/^In-Reply-To:\s*(.+)\s*$/i) {
+ $initial_reply_to = $1;
+ next;
+ } elsif (/^From:\s*(.+)\s*$/i) {
+ $sender = $1;
+ next;
+ } elsif (/^(?:To|Cc|Bcc):/i) {
+ print "To/Cc/Bcc fields are not interpreted yet, they have been ignored\n";
+ next;
+ }
+ print C2 $_;
+ }
+ close(C);
+ close(C2);
+
+ if ($summary_empty) {
+ print "Summary email is empty, skpping it\n";
+ $compose = -1;
+ }
+} elsif ($annotate) {
+ do_edit(@files);
+}
+
my $prompting = 0;
if (!defined $sender) {
$sender = $repoauthor || $repocommitter || '';
@@ -477,17 +579,6 @@ sub expand_aliases {
@initial_cc = expand_aliases(@initial_cc);
@bcclist = expand_aliases(@bcclist);
-if (!defined $initial_subject && $compose) {
- while (1) {
- $_ = $term->readline("What subject should the initial email start with? ", $initial_subject);
- last if defined $_;
- print "\n";
- }
-
- $initial_subject = $_;
- $prompting++;
-}
-
if ($thread && !defined $initial_reply_to && $prompting) {
while (1) {
$_= $term->readline("Message-ID to be used as In-Reply-To for the first email? ", $initial_reply_to);
@@ -514,64 +605,6 @@ if (!defined $smtp_server) {
}
if ($compose) {
- # Note that this does not need to be secure, but we will make a small
- # effort to have it be unique
- open(C,">",$compose_filename)
- or die "Failed to open for writing $compose_filename: $!";
- print C "From $sender # This line is ignored.\n";
- printf C "Subject: %s\n\n", $initial_subject;
- printf C <<EOT;
-GIT: Please enter your email below.
-GIT: Lines beginning in "GIT: " will be removed.
-GIT: Consider including an overall diffstat or table of contents
-GIT: for the patch you are writing.
-
-EOT
- close(C);
-
- my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
-
- if ($annotate) {
- do_edit($compose_filename, @files);
- } else {
- do_edit($compose_filename);
- }
-
- open(C2,">",$compose_filename . ".final")
- or die "Failed to open $compose_filename.final : " . $!;
-
- open(C,"<",$compose_filename)
- or die "Failed to open $compose_filename : " . $!;
-
- my $need_8bit_cte = file_has_nonascii($compose_filename);
- my $in_body = 0;
- while(<C>) {
- next if m/^GIT: /;
- if (!$in_body && /^\n$/) {
- $in_body = 1;
- if ($need_8bit_cte) {
- print C2 "MIME-Version: 1.0\n",
- "Content-Type: text/plain; ",
- "charset=utf-8\n",
- "Content-Transfer-Encoding: 8bit\n";
- }
- }
- if (!$in_body && /^MIME-Version:/i) {
- $need_8bit_cte = 0;
- }
- if (!$in_body && /^Subject: ?(.*)/i) {
- my $subject = $1;
- $_ = "Subject: " .
- ($subject =~ /[^[:ascii:]]/ ?
- quote_rfc2047($subject) :
- $subject) .
- "\n";
- }
- print C2 $_;
- }
- close(C);
- close(C2);
-
while (1) {
$_ = $term->readline("Send this email? (y|n) ");
last if defined $_;
@@ -583,9 +616,9 @@ EOT
exit(0);
}
- @files = ($compose_filename . ".final", @files);
-} elsif ($annotate) {
- do_edit(@files);
+ if ($compose > 0) {
+ @files = ($compose_filename . ".final", @files);
+ }
}
# Variables we set as part of the loop over files
--
1.5.6.5
^ permalink raw reply related
* [PATCH 3/5] git send-email: add --annotate option
From: Pierre Habouzit @ 2008-11-04 16:24 UTC (permalink / raw)
To: git; +Cc: Pierre Habouzit
In-Reply-To: <1225815858-30617-3-git-send-email-madcoder@debian.org>
This allows to review every patch (and fix various aspects of them, or
comment them) in an editor just before being sent. Combined to the fact
that git send-email can now process revision lists, this makes git
send-email and efficient way to review and send patches interactively.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
Documentation/git-send-email.txt | 11 +++++++++++
git-send-email.perl | 26 ++++++++++++++++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 4654d4f..39d6da9 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -37,6 +37,11 @@ The --bcc option must be repeated for each user you want on the bcc list.
+
The --cc option must be repeated for each user you want on the cc list.
+--annotate::
+ Review each patch you're about to send in an editor. The setting
+ 'sendemail.multiedit' defines if this will spawn one editor per patch
+ or one for all of them at once.
+
--compose::
Use $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an
introductory message for the patch series.
@@ -204,6 +209,12 @@ sendemail.aliasfiletype::
Format of the file(s) specified in sendemail.aliasesfile. Must be
one of 'mutt', 'mailrc', 'pine', or 'gnus'.
+sendemail.multiedit::
+ If true (default), a single editor instance will be spawned to edit
+ files you have to edit (patches when '--annotate' is used, and the
+ summary when '--compose' is used). If false, files will be edited one
+ after the other, spawning a new editor each time.
+
Author
------
diff --git a/git-send-email.perl b/git-send-email.perl
index c29868a..d0c5a41 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -50,6 +50,7 @@ git send-email [options] <file | directory | rev-list options >
--bcc <str> * Email Bcc:
--subject <str> * Email "Subject:"
--in-reply-to <str> * Email "In-Reply-To:"
+ --annotate * Review each patch that will be sent in an editor.
--compose * Open an editor for introduction.
Sending:
@@ -129,7 +130,8 @@ sub cleanup_compose_files();
# Variables we fill in automatically, or via prompting:
my (@to,@cc,@initial_cc,@bcclist,@xh,
- $initial_reply_to,$initial_subject,@files,$author,$sender,$smtp_authpass,$compose,$time);
+ $initial_reply_to,$initial_subject,@files,
+ $author,$sender,$smtp_authpass,$annotate,$compose,$time);
my $envelope_sender;
@@ -151,6 +153,17 @@ if ($@) {
my ($quiet, $dry_run) = (0, 0);
my $compose_filename = $repo->repo_path() . "/.gitsendemail.msg.$$";
+# Handle interactive edition of files.
+my $multiedit;
+my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
+sub do_edit {
+ if (defined($multiedit) && !$multiedit) {
+ map { system('sh', '-c', $editor.' "$@"', $editor, $_); } @_;
+ } else {
+ system('sh', '-c', $editor.' "$@"', $editor, @_);
+ }
+}
+
# Variables with corresponding config settings
my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);
my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);
@@ -180,6 +193,7 @@ my %config_settings = (
"aliasesfile" => \@alias_files,
"suppresscc" => \@suppress_cc,
"envelopesender" => \$envelope_sender,
+ "multiedit" => \$multiedit,
);
# Handle Uncouth Termination
@@ -222,6 +236,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
"smtp-ssl" => sub { $smtp_encryption = 'ssl' },
"smtp-encryption=s" => \$smtp_encryption,
"identity=s" => \$identity,
+ "annotate" => \$annotate,
"compose" => \$compose,
"quiet" => \$quiet,
"cc-cmd=s" => \$cc_cmd,
@@ -515,7 +530,12 @@ EOT
close(C);
my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
- system('sh', '-c', $editor.' "$@"', $editor, $compose_filename);
+
+ if ($annotate) {
+ do_edit($compose_filename, @files);
+ } else {
+ do_edit($compose_filename);
+ }
open(C2,">",$compose_filename . ".final")
or die "Failed to open $compose_filename.final : " . $!;
@@ -564,6 +584,8 @@ EOT
}
@files = ($compose_filename . ".final", @files);
+} elsif ($annotate) {
+ do_edit(@files);
}
# Variables we set as part of the loop over files
--
1.5.6.5
^ permalink raw reply related
* [PATCH 2/5] git send-email: interpret unknown files as revision lists
From: Pierre Habouzit @ 2008-11-04 16:24 UTC (permalink / raw)
To: git; +Cc: Pierre Habouzit
In-Reply-To: <1225815858-30617-2-git-send-email-madcoder@debian.org>
Filter out all the arguments git-send-email doesn't like to a
git format-patch command, that dumps its content to a safe directory.
Barf when a file/revision conflict occurs.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
Documentation/git-send-email.txt | 2 +-
git-send-email.perl | 28 ++++++++++++++++++++++++----
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 82f5056..4654d4f 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -8,7 +8,7 @@ git-send-email - Send a collection of patches as emails
SYNOPSIS
--------
-'git send-email' [options] <file|directory> [... file|directory]
+'git send-email' [options] <file|directory|rev-list options>...
DESCRIPTION
diff --git a/git-send-email.perl b/git-send-email.perl
index aaace02..c29868a 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -22,8 +22,11 @@ use Term::ReadLine;
use Getopt::Long;
use Data::Dumper;
use Term::ANSIColor;
+use File::Temp qw/ tempdir /;
use Git;
+Getopt::Long::Configure qw/ pass_through /;
+
package FakeTerm;
sub new {
my ($class, $reason) = @_;
@@ -38,7 +41,7 @@ package main;
sub usage {
print <<EOT;
-git send-email [options] <file | directory>...
+git send-email [options] <file | directory | rev-list options >
Composing:
--from <str> * Email From:
@@ -363,10 +366,22 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {
($sender) = expand_aliases($sender) if defined $sender;
+sub check_file_rev_conflict($) {
+ my $f = shift;
+ if ($repo->command('rev-parse', '--verify', '--quiet', $f)) {
+ die("revision/filename conflict on `$f'");
+ }
+}
+
# Now that all the defaults are set, process the rest of the command line
# arguments and collect up the files that need to be processed.
-for my $f (@ARGV) {
- if (-d $f) {
+my @rev_list_opts;
+while (my $f = pop @ARGV) {
+ if ($f eq "--") {
+ push @rev_list_opts, "--", @ARGV;
+ @ARGV = ();
+ } elsif (-d $f) {
+ check_file_rev_conflict($f);
opendir(DH,$f)
or die "Failed to opendir $f: $!";
@@ -374,12 +389,17 @@ for my $f (@ARGV) {
sort readdir(DH);
closedir(DH);
} elsif (-f $f or -p $f) {
+ check_file_rev_conflict($f);
push @files, $f;
} else {
- print STDERR "Skipping $f - not found.\n";
+ push @rev_list_opts, $f;
}
}
+if (@rev_list_opts) {
+ push @files, $repo->command('format-patch', '-o', tempdir(CLEANUP => 1), @rev_list_opts);
+}
+
if ($validate) {
foreach my $f (@files) {
unless (-p $f) {
--
1.5.6.5
^ permalink raw reply related
* [PATCH 1/5] git send-email: make the message file name more specific.
From: Pierre Habouzit @ 2008-11-04 16:24 UTC (permalink / raw)
To: git; +Cc: Pierre Habouzit
In-Reply-To: <1225815858-30617-1-git-send-email-madcoder@debian.org>
This helps editors choosing their syntax hilighting properly.
Also make the file live under the git directory.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
git-send-email.perl | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 94ca5c8..aaace02 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -124,9 +124,6 @@ my $auth;
sub unique_email_list(@);
sub cleanup_compose_files();
-# Constants (essentially)
-my $compose_filename = ".msg.$$";
-
# Variables we fill in automatically, or via prompting:
my (@to,@cc,@initial_cc,@bcclist,@xh,
$initial_reply_to,$initial_subject,@files,$author,$sender,$smtp_authpass,$compose,$time);
@@ -149,6 +146,7 @@ if ($@) {
# Behavior modification variables
my ($quiet, $dry_run) = (0, 0);
+my $compose_filename = $repo->repo_path() . "/.gitsendemail.msg.$$";
# Variables with corresponding config settings
my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);
--
1.5.6.5
^ permalink raw reply related
* [take 2] git send-email updates
From: Pierre Habouzit @ 2008-11-04 16:24 UTC (permalink / raw)
To: git
In-Reply-To: <1225450632-7230-1-git-send-email-madcoder@debian.org>
[PATCH 1/5] git send-email: make the message file name more specific.
self described
[PATCH 2/5] git send-email: interpret unknown files as revision lists
All unknown arguments are passed to git-format-patch at once,
checking for possible file/rev conflicts and dying in that case,
like Junio suggested.
[PATCH 3/5] git send-email: add --annotate option
same as before.
[PATCH 4/5] git send-email: ask less questions when --compose is used.
same as before, with an update wrt empty bodies. Still doesn't grok
To/Cc/Bcc. I would be really glad if a patch to deal with it was
appended to that series, but a patch that deals with Header
continuations well.
[PATCH 5/5] git send-email: turn --compose on when more than one patch.
This patch is probably controversial. I propose it not because I'm
lazy, I now have a 'git send' alias for the task that expands to
'send-email -C -C -M -n --annotate --compose --to'. I propose it
because I believe it's a good thing to make people write about their
stuff when there is a series and not a single patch. If they still
don't want to, they just have to clear the mail buffer at once.
The drawback is that it _may_ break some scripts, those people would
have to pass --no-compose to their send-email call to fix the
scripts.
I wouldn't complain if the patch gets dropped.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
^ permalink raw reply
* Re: libxdiff and patience diff
From: Pierre Habouzit @ 2008-11-04 16:15 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: davidel, Git ML
In-Reply-To: <alpine.DEB.1.00.0811041650510.24407@pacific.mpi-cbg.de>
[-- Attachment #1: Type: text/plain, Size: 2571 bytes --]
On Tue, Nov 04, 2008 at 03:57:44PM +0000, Johannes Schindelin wrote:
> Hi,
>
> On Tue, 4 Nov 2008, Pierre Habouzit wrote:
>
> > The nasty thing about the patience diff is that it still needs the usual
> > diff algorithm once it has split the file into chunks separated by
> > "unique lines".
>
> Actually, it should try to apply patience diff again in those chunks,
> separately.
yes it's what I do, but this has a fixed point as soon as you don't find
unique lines between the new found ones, or that that space is "empty".
E.g. you could have the two following hunks:
File A File B
1 2
2 1
1 2
2 1
1 2
2
1
The simple leading/trailing reduction will do nothing, and you don't
have any shared unique lines, on that you must apply the usual diff
algorithm.
> > So you cannot make really independant stuff. What I could do is put most
> > of the xpatience diff into xpatience.c but it would still have to use
> > some functions from xdiffi.c that are currently private, so it messes
> > somehow the files more than it's worth IMHO.
>
> I think it is better that you use the stuff from xdiffi.c through a well
> defined interface, i.e. _not_ mess up the code by mingling it together
> with the code in xdiffi.c. The code is hard enough to read already.
Hmmm. I'll see to that later, once I have something that works.
> Oh, BTW, "ha" is a hash of the lines which is used to make the line
> matching more performant. You will see a lot of "ha" comparisons before
> actually calling xdl_recmatch() for that reason. Incidentally, this is
> also the hash that I'd use for the hash multi-set I was referring to.
Yeah, that's what I assumed it would be.
> Oh, and I am not sure that it is worth your time trying to get it to run
> with the linear list, since you cannot reuse that code afterwards, and
> have to spend the same amount of time to redo it with the hash set.
Having the linear list (actually an array) work would show me I hook at
the proper place. Replacing a data structure doesn't makes me afraid
because I've split the functions properly.
> I am awfully short on time, so it will take some days until I can review
> what you have already, unfortunately.
NP, it was just in case, because I'm horribly stuck with that code right
now ;)
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: libxdiff and patience diff
From: Johannes Schindelin @ 2008-11-04 15:57 UTC (permalink / raw)
To: Pierre Habouzit; +Cc: davidel, Git ML
In-Reply-To: <20081104152351.GA21842@artemis.corp>
Hi,
On Tue, 4 Nov 2008, Pierre Habouzit wrote:
> The nasty thing about the patience diff is that it still needs the usual
> diff algorithm once it has split the file into chunks separated by
> "unique lines".
Actually, it should try to apply patience diff again in those chunks,
separately.
> So you cannot make really independant stuff. What I could do is put most
> of the xpatience diff into xpatience.c but it would still have to use
> some functions from xdiffi.c that are currently private, so it messes
> somehow the files more than it's worth IMHO.
I think it is better that you use the stuff from xdiffi.c through a well
defined interface, i.e. _not_ mess up the code by mingling it together
with the code in xdiffi.c. The code is hard enough to read already.
Oh, BTW, "ha" is a hash of the lines which is used to make the line
matching more performant. You will see a lot of "ha" comparisons before
actually calling xdl_recmatch() for that reason. Incidentally, this is
also the hash that I'd use for the hash multi-set I was referring to.
Oh, and I am not sure that it is worth your time trying to get it to run
with the linear list, since you cannot reuse that code afterwards, and
have to spend the same amount of time to redo it with the hash set.
I am awfully short on time, so it will take some days until I can review
what you have already, unfortunately.
Ciao,
Dscho
^ permalink raw reply
* Re: libxdiff and patience diff
From: Pierre Habouzit @ 2008-11-04 15:23 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: davidel, Git ML
In-Reply-To: <alpine.DEB.1.00.0811041447170.24407@pacific.mpi-cbg.de>
[-- Attachment #1.1: Type: text/plain, Size: 5442 bytes --]
On Tue, Nov 04, 2008 at 02:34:37PM +0000, Johannes Schindelin wrote:
> Hi,
>
> On Tue, 4 Nov 2008, Pierre Habouzit wrote:
>
> > On Tue, Nov 04, 2008 at 05:39:48AM +0000, Johannes Schindelin wrote:
> >
> > > On Tue, 4 Nov 2008, Pierre Habouzit wrote:
> > >
> > > > I've been working tonight, trying to make libxdiff support the
> > > > patience diff algorithm, but I've totally failed, because I
> > > > _thought_ I understood what xdl_split was doing, but it appears I
> > > > don't.
> > >
> > > I thought about it, too, at the GitTogether, although I want to finish
> > > my jGit diff first.
> > >
> > > The main idea I had about patience diff is that you can reuse a lot of
> > > functions in libxdiff.
> > >
> > > But the requirement of taking just unique lines/hashes into account,
> > > and _after_ splitting up, _again_ determine uniqueness _just_ in the
> > > between-hunk part made me think that it may be wiser to have a
> > > separate function for the patience diff stuff.
> > >
> > > Basically, you would start to have libxdiff split the lines and hash
> > > them as normal, but then determine the unique hashes (I'd start with
> > > the smaller text, just to have a better chance to end up with unique
> > > hashes).
> > >
> > > Once they are determined, you can search for those exact lines (hash
> > > first) in the post-document.
> >
> > Actually my current implementation just puts all the hashes into an
> > array, sorts them by hash (which is O(n log(n)) with the position from
> > left or right file it's in, ordered by increasing right position. (and
> > the struct is filled with the left pos to -1 if the right pos is set,
> > and vice versa).
>
> Yeah, that would be much more efficient using a hash-multiset. Still
> linear size (albeit twice as much). And you can already discard double
> entries early (although you have to keep one pointer in the hash-multiset
> to prevent other identical lines from being misdetected as "unique").
Probably, I just wanted something to work first, and then optimize it
using the proper structure.
> I am not sure that you really end up with patience diff that way. I
> _think_ that you need to determine the longest sequence of unique lines
> which has the property of being ordered in both texts first, and only
> _then_ recurse into the not-yet-handled lines.
I must have been using really bad english because it's what I do ;)
> > > Once that is done, you'd have to find the longest common subsequence,
> > > which you could do using the existing infrastructure, but that would
> > > require more work (as we already know the lines are unique).
> >
> > Patience diff gives you the algorithm to do that, it's pretty simple,
> > and is more efficient than the current infrastructure (in time, I don't
> > know for space though).
>
> Actually, IIRC it is pretty easy to see that the time complexity is linear
> (and therefore, the space complexity, too).
Well the space complexity of the patience diff would be linear too for
me, though I'm afraid that the current state of my implementation has a
big factor front ;)
> > In fact when I look at the records I have in xdiffi.c I had the
> > impression they were already somehow collapsed, which makes it a too
> > late point to apply the patience diff ...
>
> AFAICS xdiffi.c contains the classical diff algorithm (incidentally, I the
> inventor of that algorithm is about 50 meters away from me at this very
> moment). It should not have anything of interest to you, except for the
> fall-back case.
>
> So I think that you should add a new file xpatience.c.
>
> In that, I'd implement that hash multi-set, and use a prepared xdfenv_t to
> fill it (smaller file first, then you can traverse the other file,
> checking for uniqueness in that file and for a match in the other file at
> the same time).
>
> You _could_ build the longest list of ordered pairs at the same time, too,
> but that may make the code a bit too complex.
Well, technically, if I'm correct, xdiffi.c already has a pruned list of
hashed (I suppose ->ha is a hash value somehow ?) lines (pruned from
lines without a match left or right), and I was massaging that. Though
it absolutely fails so I fear I didn't understand what the ha stuff is
for real.
Attached is my current work (YES it is horrible, it's WIP), probably
most of it can be put in an xpatience.c file, but still, I absolutely
don't understand what gets wrong. On the simple example from
glandium.org it _looks_ like it catches the "unique" include line fine,
but somehow not.
The nasty thing about the patience diff is that it still needs the usual
diff algorithm once it has split the file into chunks separated by
"unique lines". So you cannot make really independant stuff. What I
could do is put most of the xpatience diff into xpatience.c but it would
still have to use some functions from xdiffi.c that are currently
private, so it messes somehow the files more than it's worth IMHO.
Anyways, I'm waiting for a client to finally setup his network for the
test I'm supposed to do right now, I'll try to have a closer look
tonight...
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #1.2: wip.patch --]
[-- Type: text/plain, Size: 8642 bytes --]
diff --git a/diff.c b/diff.c
index f644947..0901cdc 100644
--- a/diff.c
+++ b/diff.c
@@ -2447,6 +2447,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
options->xdl_opts |= XDF_IGNORE_WHITESPACE_CHANGE;
else if (!strcmp(arg, "--ignore-space-at-eol"))
options->xdl_opts |= XDF_IGNORE_WHITESPACE_AT_EOL;
+ else if (!strcmp(arg, "--patience"))
+ options->xdl_opts |= XDF_USE_PATIENCE;
/* flags options */
else if (!strcmp(arg, "--binary")) {
diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h
index 84fff58..bba915c 100644
--- a/xdiff/xdiff.h
+++ b/xdiff/xdiff.h
@@ -32,6 +32,7 @@ extern "C" {
#define XDF_IGNORE_WHITESPACE (1 << 2)
#define XDF_IGNORE_WHITESPACE_CHANGE (1 << 3)
#define XDF_IGNORE_WHITESPACE_AT_EOL (1 << 4)
+#define XDF_USE_PATIENCE (1 << 5)
#define XDF_WHITESPACE_FLAGS (XDF_IGNORE_WHITESPACE | XDF_IGNORE_WHITESPACE_CHANGE | XDF_IGNORE_WHITESPACE_AT_EOL)
#define XDL_PATCH_NORMAL '-'
diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c
index 9d0324a..1a5b13a 100644
--- a/xdiff/xdiffi.c
+++ b/xdiff/xdiffi.c
@@ -37,8 +37,235 @@ typedef struct s_xdpsplit {
int min_lo, min_hi;
} xdpsplit_t;
+typedef struct s_xduniqmatch {
+ struct s_xduniqmatch *next;
+ long i1, i2, len;
+} xduniqmatch_t;
+
+typedef struct s_xdp_ha {
+ struct s_xdp_ha *up, *down;
+ struct s_xdp_ha *left;
+ long ha;
+ long off1;
+ long off2;
+} xdp_ha_t;
+
+
+static xduniqmatch_t *xdl_uniq_match_alloc(long i1, long i2, long len)
+{
+ xduniqmatch_t *match = xdl_malloc(sizeof(xduniqmatch_t));
+ if (match) {
+ match->next = NULL;
+ match->i1 = i1;
+ match->i2 = i2;
+ match->len = len;
+ }
+ return match;
+}
+
+static xduniqmatch_t *xdl_uniq_popfree(xduniqmatch_t *lst)
+{
+ xduniqmatch_t *next = lst->next;
+ xdl_free(lst);
+ return next;
+}
+
+static int xdp_ha_cmp_by_ha(const void *a1, const void *a2)
+{
+ const xdp_ha_t *ha1 = a1;
+ const xdp_ha_t *ha2 = a2;
+ if (ha1->ha == ha2->ha) {
+ return ha1->off2 - ha2->off2;
+ }
+ return ha1->ha - ha2->ha;
+}
+
+static int xdp_ha_cmp_by_off2(const void *a1, const void *a2)
+{
+ const xdp_ha_t *ha1 = a1;
+ const xdp_ha_t *ha2 = a2;
+ return ha2->off2 - ha1->off2;
+}
+
+static int patience_bisect_stack(xdp_ha_t **stacks, long len, long off1)
+{
+ long l = 0, r = len;
+
+ while (l < r) {
+ long i = (r + l) / 2;
+
+ if (off1 < stacks[i]->off1) {
+ l = i + 1;
+ } else {
+ r = i;
+ }
+ }
+ return l;
+}
+
+static int xdl_patience_split_aux(xduniqmatch_t *lcs, xdp_ha_t *ha)
+{
+ xduniqmatch_t *tmp;
+
+ while (ha) {
+ tmp = xdl_uniq_match_alloc(ha->off1, ha->off2, 1);
+ if (!tmp)
+ return -1;
+ tmp->next = lcs->next;
+ lcs->next = tmp;
+ lcs = tmp;
+
+ while ((ha = ha->down ? ha->down : ha->left)) {
+ if (lcs->i1 + lcs->len + 1 == ha->off1 && lcs->i2 + lcs->len + 1 == ha->off2) {
+ lcs->len++;
+ continue;
+ }
+ break;
+ }
+ }
+ return 0;
+}
+
+static int xdl_patience_split(unsigned long const *ha1, unsigned long const *ha2,
+ xduniqmatch_t *begin, xduniqmatch_t *end)
+{
+ xdp_ha_t *recs;
+ long off1 = begin->i1 + begin->len, lim1 = end->i1;
+ long off2 = begin->i2 + begin->len, lim2 = end->i2;
+ long len, i, j, uniq;
+
+ len = lim1 - off1 + lim2 - off2;
+ recs = (xdp_ha_t *)xdl_malloc(sizeof(xdp_ha_t) * len);
+ if (recs == NULL)
+ return -1;
+
+ for (i = 0, j = off1; j < lim1 - off1; j++, i++) {
+ recs[i].ha = ha1[j];
+ recs[i].off1 = j;
+ recs[i].off2 = -1;
+ recs[i].up = recs[i].down = recs[i].left = NULL;
+ }
+ for (j = off2; j < lim2; j++, i++) {
+ recs[i].ha = ha2[j];
+ recs[i].off1 = -1;
+ recs[i].off2 = j;
+ recs[i].up = recs[i].down = recs[i].left = NULL;
+ }
+
+ qsort(recs, len, sizeof(xdp_ha_t), xdp_ha_cmp_by_ha);
+
+ uniq = 0;
+ for (i = 0; i < len - 1; ) {
+ long ha = recs[i].ha;
+
+ if (ha != recs[i + 1].ha) {
+ i++;
+ continue;
+ }
+
+ if (i < len - 2 && ha == recs[i + 2].ha) {
+ i += 3;
+ while (i < len - 1 && recs[i].ha == ha && i < len - 1) {
+ i++;
+ }
+ continue;
+ }
+
+ if (recs[i].off2 < 0 && recs[i + 1].off1 < 0) {
+ long a, b;
+ recs[uniq].ha = ha;
+ a = recs[uniq].off1 = recs[i].off1;
+ b = recs[uniq].off2 = recs[i + 1].off2;
+ uniq++;
+ }
+ i += 2;
+ }
+
+ if (uniq) {
+ xdp_ha_t **stacks;
+ long alloc, len;
+
+ qsort(recs, uniq, sizeof(xdp_ha_t), xdp_ha_cmp_by_off2);
+
+ alloc = xdl_bogosqrt(uniq);
+ stacks = xdl_malloc(sizeof(xdp_ha_t *) * alloc);
+ if (stacks == NULL)
+ goto error;
+ len = 1;
+ stacks[0] = recs;
+
+ for (i = 1; i < uniq; i++) {
+ long off1 = recs[i].off1;
+ long k;
+
+ if (off1 < stacks[len - 1]->off1) {
+ if (len >= alloc) {
+ alloc *= 2;
+ stacks = xdl_realloc(stacks, sizeof(xdp_ha_t *) * alloc);
+ if (!stacks)
+ goto error;
+ }
+ stacks[k = len++] = NULL;
+ } else {
+ k = patience_bisect_stack(stacks, len - 1, off1);
+ }
+
+ if (k > 0) {
+ recs[i].left = stacks[k - 1];
+ }
+ if (stacks[k]) {
+ stacks[k]->down = &recs[i];
+ recs[i].up = stacks[k];
+ }
+ stacks[k] = &recs[i];
+ }
+
+ if (xdl_patience_split_aux(begin, stacks[len - 1]) < 0) {
+ xdl_free(stacks);
+ goto error;
+ }
+
+ xdl_free(stacks);
+ }
+
+ xdl_free(recs);
+ return 0;
+
+error:
+ xdl_free(recs);
+ return -1;
+}
+
+static int xdl_patience_lcs(xdfenv_t *xe, xduniqmatch_t *begin, xduniqmatch_t *end)
+{
+ unsigned long const *ha1 = xe->xdf1.ha, *ha2 = xe->xdf2.ha;
+ long off1 = begin->i1 + begin->len, lim1 = end->i1;
+ long off2 = begin->i2 + begin->len, lim2 = end->i2;
+ xduniqmatch_t *next;
+
+ for (; off1 < lim1 && off2 < lim2 && ha1[off1] == ha2[off2]; off1++, off2++);
+ for (; off1 < lim1 && off2 < lim2 && ha1[lim1 - 1] == ha2[lim2 - 1]; lim1--, lim2--);
+
+ begin->len += off1 - begin->i1;
+ end->len += end->i1 - lim1;
+ end->i1 = lim1;
+ end->i2 = lim2;
+
+ if (off1 == lim1 || off2 == lim2)
+ return 0;
+
+ if (xdl_patience_split(ha1, ha2, begin, end))
+ return -1;
+
+ for (next = begin->next; next != end; begin = next, next = begin->next) {
+ if (xdl_patience_lcs(xe, begin, next) < 0)
+ return -1;
+ }
+
+ return 0;
+}
static long xdl_split(unsigned long const *ha1, long off1, long lim1,
unsigned long const *ha2, long off2, long lim2,
@@ -321,13 +548,13 @@ int xdl_recs_cmp(diffdata_t *dd1, long off1, long lim1,
return 0;
}
-
int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
xdfenv_t *xe) {
long ndiags;
long *kvd, *kvdf, *kvdb;
xdalgoenv_t xenv;
diffdata_t dd1, dd2;
+ int need_min = (xpp->flags & XDF_NEED_MINIMAL) != 0;
if (xdl_prepare_env(mf1, mf2, xpp, xe) < 0) {
@@ -364,12 +591,54 @@ int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
dd2.rchg = xe->xdf2.rchg;
dd2.rindex = xe->xdf2.rindex;
- if (xdl_recs_cmp(&dd1, 0, dd1.nrec, &dd2, 0, dd2.nrec,
- kvdf, kvdb, (xpp->flags & XDF_NEED_MINIMAL) != 0, &xenv) < 0) {
+ if (xpp->flags & XDF_USE_PATIENCE) {
+ xduniqmatch_t *lcs;
+ long i1, i2;
+
+ lcs = xdl_uniq_match_alloc(0, 0, 0);
+ if (!lcs)
+ goto error;
+ lcs->next = xdl_uniq_match_alloc(xe->xdf1.nreff, xe->xdf2.nreff, 0);
+ if (!lcs->next || xdl_patience_lcs(xe, lcs, lcs->next) < 0) {
+ while ((lcs = xdl_uniq_popfree(lcs)));
+ goto error;
+ }
- xdl_free(kvd);
- xdl_free_env(xe);
- return -1;
+ i1 = i2 = lcs->len;
+ if (lcs->len) {
+ fprintf(stderr, "skip %ld:%ld -> %ld:%ld\n",
+ lcs->i1, i1, lcs->i2, i2);
+ }
+
+ while ((lcs = xdl_uniq_popfree(lcs))) {
+ fprintf(stderr, "usual %ld:%ld -> %ld:%ld\n",
+ i1, lcs->i1, i2, lcs->i2);
+ fprintf(stderr, "l/r: %ld / %ld\n",
+ xe->xdf1.rindex[lcs->i1],
+ xe->xdf2.rindex[lcs->i2]);
+ if (xdl_recs_cmp(&dd1, i1, lcs->i1, &dd2, i2, lcs->i2,
+ kvdf, kvdb, need_min, &xenv) < 0) {
+ while ((lcs = xdl_uniq_popfree(lcs)));
+ goto error;
+ }
+ i1 = lcs->i1 + lcs->len;
+ i2 = lcs->i2 + lcs->len;
+ if (lcs->len) {
+ fprintf(stderr, "skip %ld:%ld -> %ld:%ld (len %ld)\n",
+ lcs->i1, i1, lcs->i2, i2, lcs->len);
+ fprintf(stderr, "l/r: %ld / %ld\n",
+ xe->xdf1.rindex[lcs->i1 + lcs->len],
+ xe->xdf2.rindex[lcs->i2 + lcs->len]);
+ }
+ }
+ } else {
+ if (xdl_recs_cmp(&dd1, 0, dd1.nrec, &dd2, 0, dd2.nrec,
+ kvdf, kvdb, need_min, &xenv) < 0) {
+error:
+ xdl_free(kvd);
+ xdl_free_env(xe);
+ return -1;
+ }
}
xdl_free(kvd);
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply related
* Re: Repo corrupted somehow?
From: Andrew Arnott @ 2008-11-04 15:12 UTC (permalink / raw)
To: git
In-Reply-To: <216e54900811032334y35ada7daw753c0ad3073c0317@mail.gmail.com>
Nah, that wasn't a false alarm after all. It's happening again, only
this time for dozens of files, and
git rebase --abort
git reset --hard
is not helping.
On Mon, Nov 3, 2008 at 11:34 PM, Andrew Arnott <andrewarnott@gmail.com> wrote:
> I guess I was still in the middle of a rebase. git rebase --abort
> sort of ultimately fixed it.
>
> On Mon, Nov 3, 2008 at 11:09 PM, Andrew Arnott <andrewarnott@gmail.com> wrote:
>> I was just git commit'ing, and then I was doing a git rebase to squash
>> several commits into one when the rebase failed. I then did a
>> git checkout -f master
>> git reset --hard
>> but no matter what I do, git thinks that several files have changed.
>> The diff shows all the lines in these several files removed and then
>> added, yet without any changes made to them. git reset --hard doesn't
>> revert the change. When I jump around history with git checkout these
>> files remain in their "changed" state. I even tried "git clone" to
>> create a whole new repo, but one of these several files STILL
>> registered as changed before I made any changes.
>>
>> Any idea what's wrong and how to recover?
>>
>> Observe the below command buffer: (I can upload my repo so you can
>> clone it and perhaps repro it if you want).
>>
>> Andrew@LACKY /c/git/dotnetoauth
>> $ git status
>> # On branch master
>> # Changed but not updated:
>> # (use "git add <file>..." to update what will be committed)
>> #
>> # modified: tools/Documentation.targets
>> # modified: tools/DotNetOpenAuth.Common.Settings.targets
>> # modified: tools/DotNetOpenAuth.Versioning.targets
>> # modified:
>> tools/Sandcastle/Presentation/vs2005/Content/reference_content.xml
>> # modified: tools/libcheck.ps1
>> # modified: tools/sandcastle.targets
>> #
>> no changes added to commit (use "git add" and/or "git commit -a")
>>
>> Andrew@LACKY /c/git/dotnetoauth
>> $ git reset --hard
>> HEAD is now at 13d37b8 Patching up the bad merges in the phases.
>>
>> Andrew@LACKY /c/git/dotnetoauth
>> $ git status
>> # On branch master
>> # Changed but not updated:
>> # (use "git add <file>..." to update what will be committed)
>> #
>> # modified: tools/Documentation.targets
>> # modified: tools/DotNetOpenAuth.Common.Settings.targets
>> # modified: tools/DotNetOpenAuth.Versioning.targets
>> # modified:
>> tools/Sandcastle/Presentation/vs2005/Content/reference_content.xml
>> # modified: tools/libcheck.ps1
>> # modified: tools/sandcastle.targets
>> #
>> no changes added to commit (use "git add" and/or "git commit -a")
>>
>
^ permalink raw reply
* Re: Stgit and refresh-temp
From: Jon Smirl @ 2008-11-04 14:50 UTC (permalink / raw)
To: Karl Hasselström, Catalin Marinas, Git Mailing List
In-Reply-To: <9e4733910811040538v604d33e3jf0b312d809630af2@mail.gmail.com>
I think I fixed my tree up. After a stg repair I was able to delete
'refresh-temp' which was empty, then apply the changes to jds-lirc.
It may have been possible to make the merge smarter. The conflicts
were with things in the popped-off patches. Your typical end of file
append merge conflicts.
On Tue, Nov 4, 2008 at 8:38 AM, Jon Smirl <jonsmirl@gmail.com> wrote:
> jonsmirl@terra:~/fs$ stg version
> Stacked GIT 0.14.3.270.g0f36
> git version 1.6.0.3.523.g304d0
> Python version 2.5.2 (r252:60911, Oct 5 2008, 19:29:17)
> [GCC 4.3.2]
> jonsmirl@terra:~/fs$
>
> --
> Jon Smirl
> jonsmirl@gmail.com
>
--
Jon Smirl
jonsmirl@gmail.com
^ permalink raw reply
* Re: libxdiff and patience diff
From: Johannes Schindelin @ 2008-11-04 14:34 UTC (permalink / raw)
To: Pierre Habouzit; +Cc: davidel, Git ML
In-Reply-To: <20081104083042.GB3788@artemis.corp>
Hi,
On Tue, 4 Nov 2008, Pierre Habouzit wrote:
> On Tue, Nov 04, 2008 at 05:39:48AM +0000, Johannes Schindelin wrote:
>
> > On Tue, 4 Nov 2008, Pierre Habouzit wrote:
> >
> > > I've been working tonight, trying to make libxdiff support the
> > > patience diff algorithm, but I've totally failed, because I
> > > _thought_ I understood what xdl_split was doing, but it appears I
> > > don't.
> >
> > I thought about it, too, at the GitTogether, although I want to finish
> > my jGit diff first.
> >
> > The main idea I had about patience diff is that you can reuse a lot of
> > functions in libxdiff.
> >
> > But the requirement of taking just unique lines/hashes into account,
> > and _after_ splitting up, _again_ determine uniqueness _just_ in the
> > between-hunk part made me think that it may be wiser to have a
> > separate function for the patience diff stuff.
> >
> > Basically, you would start to have libxdiff split the lines and hash
> > them as normal, but then determine the unique hashes (I'd start with
> > the smaller text, just to have a better chance to end up with unique
> > hashes).
> >
> > Once they are determined, you can search for those exact lines (hash
> > first) in the post-document.
>
> Actually my current implementation just puts all the hashes into an
> array, sorts them by hash (which is O(n log(n)) with the position from
> left or right file it's in, ordered by increasing right position. (and
> the struct is filled with the left pos to -1 if the right pos is set,
> and vice versa).
Yeah, that would be much more efficient using a hash-multiset. Still
linear size (albeit twice as much). And you can already discard double
entries early (although you have to keep one pointer in the hash-multiset
to prevent other identical lines from being misdetected as "unique").
> The I scan the array to find patterns of two consecutive hashes exactly,
> and collapse it into the proper {left pos, right pos} tuple if it was
> indeed a unique line in both files.
>
> This results into an array I sort again by right pos then, and we can
> work on that for the stack sorting, and I do it, and then I have my LCS.
>
>
> This is the complete brute-force algorithm which requires a temporary
> array of the size of the number of lines on the left + the right, and a
> temporary array for the stacks which _may_ end up being as large as the
> smallest number of lines between the left or right file in the worst
> case I'd say (roughly).
>
> Then I just remember a list of split points, and I recurse in all the
> sub splits again. It has a fixed point which may or may not need
> libxdiff recursion in it.
I am not sure that you really end up with patience diff that way. I
_think_ that you need to determine the longest sequence of unique lines
which has the property of being ordered in both texts first, and only
_then_ recurse into the not-yet-handled lines.
> > Once that is done, you'd have to find the longest common subsequence,
> > which you could do using the existing infrastructure, but that would
> > require more work (as we already know the lines are unique).
>
> Patience diff gives you the algorithm to do that, it's pretty simple,
> and is more efficient than the current infrastructure (in time, I don't
> know for space though).
Actually, IIRC it is pretty easy to see that the time complexity is linear
(and therefore, the space complexity, too).
> > After that, you would have to recurse to the same algorithm _between_
> > known chunks. Eventually, that would have to resort to classical
> > libxdiff (if there are no, or not enough, unique lines).
>
> Yeah, that's the point, the problem is, I believe more and more that I
> should prepare the LCS from patience diff in xprepare.c, but I grok
> absolutely nothing at what the chastore_t and similar stuff is. I
> understand it's about hashing, but the exact stuff it does eludes me.
Yes, I do not like the short and unintuitive names either.
AFAIU chastore_t is just a generic extensible array of elements that have
size "isize", and initially there are "icount" of them.
> In fact when I look at the records I have in xdiffi.c I had the
> impression they were already somehow collapsed, which makes it a too
> late point to apply the patience diff ...
AFAICS xdiffi.c contains the classical diff algorithm (incidentally, I the
inventor of that algorithm is about 50 meters away from me at this very
moment). It should not have anything of interest to you, except for the
fall-back case.
So I think that you should add a new file xpatience.c.
In that, I'd implement that hash multi-set, and use a prepared xdfenv_t to
fill it (smaller file first, then you can traverse the other file,
checking for uniqueness in that file and for a match in the other file at
the same time).
You _could_ build the longest list of ordered pairs at the same time, too,
but that may make the code a bit too complex.
Ciao,
Dscho
^ permalink raw reply
* Re: Stgit and refresh-temp
From: Jon Smirl @ 2008-11-04 13:38 UTC (permalink / raw)
To: Karl Hasselström, Catalin Marinas, Git Mailing List
In-Reply-To: <9e4733910811040537p4e88c09an94370154eca12778@mail.gmail.com>
jonsmirl@terra:~/fs$ stg version
Stacked GIT 0.14.3.270.g0f36
git version 1.6.0.3.523.g304d0
Python version 2.5.2 (r252:60911, Oct 5 2008, 19:29:17)
[GCC 4.3.2]
jonsmirl@terra:~/fs$
--
Jon Smirl
jonsmirl@gmail.com
^ permalink raw reply
* Stgit and refresh-temp
From: Jon Smirl @ 2008-11-04 13:37 UTC (permalink / raw)
To: Karl Hasselström, Catalin Marinas, Git Mailing List
I hit a case when refreshing a buried patch that needed a merge
conflict sorted out.
I'm unable to recover out of the state.
jonsmirl@terra:~/fs$ stg status
A drivers/input/ir/ir-configfs.c
A drivers/input/ir/ir-core.c
A drivers/input/ir/ir.h
C drivers/input/ir/Makefile
D drivers/input/ir-configfs.c
D drivers/input/ir-core.c
D drivers/input/ir.h
M drivers/input/Makefile
M drivers/input/input.c
jonsmirl@terra:~/fs$ gedit drivers/input/Makefile drivers/input/input.c
jonsmirl@terra:~/fs$ gedit drivers/input/ir/Makefile
jonsmirl@terra:~/fs$ stg resolve drivers/input/ir/Makefile
jonsmirl@terra:~/fs$ stg help
usage: stg <command> [options]
Generic commands:
help print the detailed command usage
version display version information
copyright display copyright information
Repository commands:
clone Make a local clone of a remote repository
id Print the git hash value of a StGit reference
Stack (branch) commands:
branch Branch operations: switch, list, create, rename, delete, ...
clean Delete the empty patches in the series
coalesce Coalesce two or more patches into one
commit Permanently store the applied patches into the stack base
float Push patches to the top, even if applied
goto Push or pop patches to the given one
hide Hide a patch in the series
init Initialise the current branch for use with StGIT
log Display the patch changelog
patches Show the applied patches modifying a file
pop Pop one or more patches from the stack
pull Pull changes from a remote repository
push Push one or more patches onto the stack
rebase Move the stack base to another point in history
redo Undo the last undo operation
repair Fix StGit metadata if branch was modified with git commands
reset Reset the patch stack to an earlier state
series Print the patch series
sink Send patches deeper down the stack
top Print the name of the top patch
uncommit Turn regular git commits into StGit patches
undo Undo the last operation
unhide Unhide a hidden patch
Patch commands:
delete Delete patches
edit edit a patch description or diff
export Export patches to a directory
files Show the files modified by a patch (or the current patch)
fold Integrate a GNU diff patch into the current patch
import Import a GNU diff file as a new patch
mail Send a patch or series of patches by e-mail
new Create a new, empty patch
pick Import a patch from a different branch or a commit object
refresh Generate a new commit for the current patch
rename Rename a patch
show Show the commit corresponding to a patch
sync Synchronise patches with a branch or a series
Index/worktree commands:
diff Show the tree diff
resolved Mark a file conflict as solved
status Show the tree status
jonsmirl@terra:~/fs$ stg help coalesce
jonsmirl@terra:~/fs$ stg series
+ Makefile
+ anton_1
+ anton_3
+ add-of_find_i2c_device_by_node
+ jds_platform
+ max9485
+ jds-soc-machine
+ jds-psc-c
+ soc-u32-cleanup
+ jds-audio
+ g_spi_4
+ m_1
+ spi-mmc
+ mpc5200-rtc
+ lirc
+ jds-lirc
> refresh-temp
- jds-lirc-gpt
- jds-lirc-device-tree
- jds-lirc-mce2
jonsmirl@terra:~/fs$ ls
arch Documentation init MAINTAINERS net
samples usr vmlinux.strip.gz
block drivers ipc Makefile patches-master scripts virt
COPYING firmware Kbuild mm patches-save
security vmlinux
CREDITS fs kernel modules.order README sound
vmlinux.bin.gz
crypto include lib Module.symvers REPORTING-BUGS
System.map vmlinux.o
jonsmirl@terra:~/fs$ mv patches-master patches-foo
jonsmirl@terra:~/fs$ stg export
Checking for changes in the working directory ... done
Warning: Local changes in the tree; you might want to commit them first
jonsmirl@terra:~/fs$ stg status
A drivers/input/ir/ir-configfs.c
A drivers/input/ir/ir-core.c
A drivers/input/ir/ir.h
D drivers/input/ir-configfs.c
D drivers/input/ir-core.c
D drivers/input/ir.h
M drivers/input/Makefile
M drivers/input/input.c
M drivers/input/ir/Makefile
jonsmirl@terra:~/fs$ ls patches-master
add-of_find_i2c_device_by_node g_spi_4 jds_platform lirc
max9485 series
anton_1 jds-audio jds-psc-c m_1
mpc5200-rtc soc-u32-cleanup
anton_3 jds-lirc jds-soc-machine Makefile
refresh-temp spi-mmc
jonsmirl@terra:~/fs$ vi patches-master/refresh-temp
jonsmirl@terra:~/fs$ stg series
+ Makefile
+ anton_1
+ anton_3
+ add-of_find_i2c_device_by_node
+ jds_platform
+ max9485
+ jds-soc-machine
+ jds-psc-c
+ soc-u32-cleanup
+ jds-audio
+ g_spi_4
+ m_1
+ spi-mmc
+ mpc5200-rtc
+ lirc
+ jds-lirc
> refresh-temp
- jds-lirc-gpt
- jds-lirc-device-tree
- jds-lirc-mce2
jonsmirl@terra:~/fs$ stg refresh -p jds-lirc
Error: HEAD and top are not the same.
This can happen if you modify a branch with git.
"stg repair --help" explains more about what to do next.
stg refresh: Command aborted (all changes rolled back)
jonsmirl@terra:~/fs$ stg refresh
Error: HEAD and top are not the same.
This can happen if you modify a branch with git.
"stg repair --help" explains more about what to do next.
stg refresh: Command aborted (all changes rolled back)
jonsmirl@terra:~/fs$ stg new foo
Invoking the editor: "vi .stgit-new.txt" ... done
Error: HEAD and top are not the same.
This can happen if you modify a branch with git.
"stg repair --help" explains more about what to do next.
stg new: Command aborted (all changes rolled back)
jonsmirl@terra:~/fs$ stg new foo
Invoking the editor: "vi .stgit-new.txt" ... done
Error: HEAD and top are not the same.
This can happen if you modify a branch with git.
"stg repair --help" explains more about what to do next.
stg new: Command aborted (all changes rolled back)
jonsmirl@terra:~/fs$ stg repair --help
Usage: stg repair
Fix StGit metadata if branch was modified with git commands
Options:
-h, --help show this help message and exit
jonsmirl@terra:~/fs$
--
Jon Smirl
jonsmirl@gmail.com
^ 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