* [TopGit TOY PATCH] tg-graft: forge tip--base--<deps...> history for a subcommand
@ 2008-08-12 21:10 Thomas Rast
2008-08-13 7:10 ` Bert Wesarg
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Rast @ 2008-08-12 21:10 UTC (permalink / raw)
To: git; +Cc: Petr Baudis
Adds a command 'tg graft <command>' that evaluates <command> with a
special GIT_GRAFT_FILE: the parent of each patch head is its patch
base, and the parents of the patch base are the dependencies of the
patch.
Try, for example, 'tg graft "gitk --all"'.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
Mainly sending this so someone can turn it into a useful feature, and
maybe build a few subcommands on top of it (that might call gitk or
'git log --graph', for example).
The one big issue with the resulting history is that the commit
messages at the tip aren't very interesting and may even be completely
irrelevant (for a base merge). I don't see a good solution for that.
Makefile | 2 +-
tg-graft.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 1 deletions(-)
create mode 100755 tg-graft.sh
diff --git a/Makefile b/Makefile
index 6eade1e..57745c0 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ sharedir = $(PREFIX)/share/topgit
hooksdir = $(cmddir)/hooks
-commands_in = tg-create.sh tg-delete.sh tg-export.sh tg-info.sh tg-patch.sh tg-summary.sh tg-update.sh
+commands_in = tg-create.sh tg-delete.sh tg-export.sh tg-info.sh tg-patch.sh tg-summary.sh tg-update.sh tg-graft.sh
hooks_in = hooks/pre-commit.sh
commands_out = $(patsubst %.sh,%,$(commands_in))
diff --git a/tg-graft.sh b/tg-graft.sh
new file mode 100755
index 0000000..b6d0458
--- /dev/null
+++ b/tg-graft.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+# TopGit - A different patch queue manager
+# (c) Petr Baudis <pasky@suse.cz> 2008
+# GPLv2
+
+if [ -z "$1" -o -n "$2" ]; then
+ echo "Usage: tg graft <command>" >&2
+ exit 1
+fi
+
+mkdir -p "$git_dir"/info
+
+grafts_file="$(mktemp)"
+
+if [ -f "$git_dir"/info/grafts ]; then
+ cp "$git_dir"/info/grafts "$grafts_file"
+fi
+
+mapdir="$(mktemp -d)"
+
+git for-each-ref refs/top-bases |
+ while read rev name ref; do
+ name="${ref#refs/top-bases/}"
+ tip=$(git rev-parse "$name")
+ base=$(git rev-parse "$ref")
+ if [ "$tip" != "$base" ]; then
+ echo $base >> "$mapdir"/$tip
+ fi
+ git cat-file blob "$name:.topdeps" |
+ while read dep; do
+ if git rev-parse --verify "$dep" >/dev/null 2>&1; then
+ rev=$(git rev-parse "$dep")
+ [ $rev != $base ] && echo $rev >> "$mapdir"/$base
+ fi
+ done
+ done
+
+for sha in $(cd "$mapdir" && ls); do
+ echo $sha $(cat "$mapdir"/$sha | sort -u) >> "$grafts_file"
+done
+
+rm -rf "$mapdir"
+
+export GIT_GRAFT_FILE="$grafts_file"
+eval "$1"
+
+rm "$grafts_file"
--
1.6.0.rc2.53.gfa6b9
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [TopGit TOY PATCH] tg-graft: forge tip--base--<deps...> history for a subcommand
2008-08-12 21:10 [TopGit TOY PATCH] tg-graft: forge tip--base--<deps...> history for a subcommand Thomas Rast
@ 2008-08-13 7:10 ` Bert Wesarg
2008-08-13 7:11 ` [TopGit PATCH] Makefile: Use $(wildcard) for commands_in Bert Wesarg
0 siblings, 1 reply; 3+ messages in thread
From: Bert Wesarg @ 2008-08-13 7:10 UTC (permalink / raw)
To: Thomas Rast; +Cc: git, Petr Baudis
On Tue, Aug 12, 2008 at 23:10, Thomas Rast <trast@student.ethz.ch> wrote:
> Adds a command 'tg graft <command>' that evaluates <command> with a
> special GIT_GRAFT_FILE: the parent of each patch head is its patch
> base, and the parents of the patch base are the dependencies of the
> patch.
>
> Try, for example, 'tg graft "gitk --all"'.
>
> Signed-off-by: Thomas Rast <trast@student.ethz.ch>
> ---
>
> Mainly sending this so someone can turn it into a useful feature, and
> maybe build a few subcommands on top of it (that might call gitk or
> 'git log --graph', for example).
>
> The one big issue with the resulting history is that the commit
> messages at the tip aren't very interesting and may even be completely
> irrelevant (for a base merge). I don't see a good solution for that.
>
> Makefile | 2 +-
> tg-graft.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 48 insertions(+), 1 deletions(-)
> create mode 100755 tg-graft.sh
>
> diff --git a/Makefile b/Makefile
> index 6eade1e..57745c0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -6,7 +6,7 @@ sharedir = $(PREFIX)/share/topgit
> hooksdir = $(cmddir)/hooks
>
>
> -commands_in = tg-create.sh tg-delete.sh tg-export.sh tg-info.sh tg-patch.sh tg-summary.sh tg-update.sh
> +commands_in = tg-create.sh tg-delete.sh tg-export.sh tg-info.sh tg-patch.sh tg-summary.sh tg-update.sh tg-graft.sh
Petr, maybe we should use a wildcard here, to prevent merge conflicts
while adding new commands.
I will send a patch.
> hooks_in = hooks/pre-commit.sh
>
> commands_out = $(patsubst %.sh,%,$(commands_in))
> diff --git a/tg-graft.sh b/tg-graft.sh
> new file mode 100755
> index 0000000..b6d0458
> --- /dev/null
> +++ b/tg-graft.sh
> @@ -0,0 +1,47 @@
> +#!/bin/sh
> +# TopGit - A different patch queue manager
> +# (c) Petr Baudis <pasky@suse.cz> 2008
> +# GPLv2
> +
> +if [ -z "$1" -o -n "$2" ]; then
> + echo "Usage: tg graft <command>" >&2
> + exit 1
> +fi
> +
> +mkdir -p "$git_dir"/info
This shouldn't be needed, the info dir is created by git init.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [TopGit PATCH] Makefile: Use $(wildcard) for commands_in
2008-08-13 7:10 ` Bert Wesarg
@ 2008-08-13 7:11 ` Bert Wesarg
0 siblings, 0 replies; 3+ messages in thread
From: Bert Wesarg @ 2008-08-13 7:11 UTC (permalink / raw)
To: Petr Baudis; +Cc: Bert Wesarg, git
To prevent merge conflicts while adding new commands, use a wildcard for
the command list.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index 6eade1e..2c4a67c 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ sharedir = $(PREFIX)/share/topgit
hooksdir = $(cmddir)/hooks
-commands_in = tg-create.sh tg-delete.sh tg-export.sh tg-info.sh tg-patch.sh tg-summary.sh tg-update.sh
+commands_in = $(wildcard tg-*.sh)
hooks_in = hooks/pre-commit.sh
commands_out = $(patsubst %.sh,%,$(commands_in))
--
tg: (f27e693..) t/use-wildcard-for-commands_in (depends on: master)
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-08-13 7:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-12 21:10 [TopGit TOY PATCH] tg-graft: forge tip--base--<deps...> history for a subcommand Thomas Rast
2008-08-13 7:10 ` Bert Wesarg
2008-08-13 7:11 ` [TopGit PATCH] Makefile: Use $(wildcard) for commands_in Bert Wesarg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).