git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cg-log: make -r id:id show the given id instead of nothing
@ 2005-05-20 15:04 Jonas Fonseca
  2005-05-29 12:19 ` Petr Baudis
  0 siblings, 1 reply; 3+ messages in thread
From: Jonas Fonseca @ 2005-05-20 15:04 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

If cg-log is passed -r cogito-0.10 -r cogito-0.10 no log entries are
shown. This patch make it show the log for the given ID.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>

Index: cg-log
===================================================================
--- ca5fef50fb68a3afbb35e1a48ac622f7a964f021/cg-log  (mode:100755)
+++ uncommitted/cg-log  (mode:100755)
@@ -113,6 +113,9 @@
 if [ "$log_end" ]; then
 	id1="$(commit-id $log_start)" || exit 1
 	id2="$(commit-id $log_end)" || exit 1
+	if [ "$id1" = "$id2" ]; then
+		id1=$(git-cat-file commit $id1 | sed -n '/^parent /,0s/parent //p')
+	fi
 	revls="git-rev-tree $id2 ^$id1"
 	revsort="sort -rn"
 	revfmt="git-rev-tree"
-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cg-log: make -r id:id show the given id instead of nothing
  2005-05-20 15:04 [PATCH] cg-log: make -r id:id show the given id instead of nothing Jonas Fonseca
@ 2005-05-29 12:19 ` Petr Baudis
  2005-05-29 13:07   ` Jonas Fonseca
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Baudis @ 2005-05-29 12:19 UTC (permalink / raw)
  To: Jonas Fonseca; +Cc: git

Dear diary, on Fri, May 20, 2005 at 05:04:00PM CEST, I got a letter
where Jonas Fonseca <fonseca@diku.dk> told me that...
> If cg-log is passed -r cogito-0.10 -r cogito-0.10 no log entries are
> shown. This patch make it show the log for the given ID.
> 
> Signed-off-by: Jonas Fonseca <fonseca@diku.dk>

I don't like such a special case a lot. If you just want to make it
possible to show up just a single revision by cg-log, what about -R or
something, so that you don't need to write it twice?

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cg-log: make -r id:id show the given id instead of nothing
  2005-05-29 12:19 ` Petr Baudis
@ 2005-05-29 13:07   ` Jonas Fonseca
  0 siblings, 0 replies; 3+ messages in thread
From: Jonas Fonseca @ 2005-05-29 13:07 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

Petr Baudis <pasky@ucw.cz> wrote Sun, May 29, 2005:
> Dear diary, on Fri, May 20, 2005 at 05:04:00PM CEST, I got a letter
> where Jonas Fonseca <fonseca@diku.dk> told me that...
> > If cg-log is passed -r cogito-0.10 -r cogito-0.10 no log entries are
> > shown. This patch make it show the log for the given ID.
> > 
> > Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
> 
> I don't like such a special case a lot. If you just want to make it
> possible to show up just a single revision by cg-log, what about -R or
> something, so that you don't need to write it twice?

I admit it is a bit weird. The reason for this was to make support for
specifying revisions with something as fuzzy as dates more usable.
Originally I modified commit-id to support it, but I've tried to move
the logic to the new cg-Xnormid to just give an idea. It is suppose to
add support for

	$ cg-log -r '2005-05-12':'1 day ago'

but for some reason it seems to only work as expected for commits by
you. That is it works as expected when I specify the dates for
cogito-0.9 and cogito-0.10.

Of course supporting revisions via date specifications can lead to
ambiguity problems when the date contains `HH:MM' because the colon can
confuse -r option parsing. This means that either a new option needs to
be added (-D?) or the rev1:rev2 case has to be handled after all options
has been parsed so that `-r date1 -r date2' can be handled correctly.

Index: cg-Xnormid
===================================================================
--- c8e987e5e4608c1144293cd3f852210d70b572cb/cg-Xnormid  (mode:100755)
+++ uncommitted/cg-Xnormid  (mode:100755)
@@ -40,6 +40,14 @@
 	fi
 fi
 
+if [ ${#id} -ne 40 ] || [ ! -f .git/objects/${id:0:2}/${id:2} ]; then
+	reqsecs=$(date --date="$id" +'%s' 2>/dev/null)
+
+	if [ "$reqsecs" ]; then
+		id=$(git-rev-list --min-age=$reqsecs --max-count=1 HEAD)
+	fi
+fi
+
 # If we don't have a 40-char ID by now, it's an error
 if [ ${#id} -ne 40 ] || [ ! -f .git/objects/${id:0:2}/${id:2} ]; then
 	echo "Invalid id: $id" >&2
-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-05-29 13:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-20 15:04 [PATCH] cg-log: make -r id:id show the given id instead of nothing Jonas Fonseca
2005-05-29 12:19 ` Petr Baudis
2005-05-29 13:07   ` Jonas Fonseca

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).