aboutsummaryrefslogtreecommitdiff
path: root/sha1_name.c
Commit message (Collapse)AuthorAge
* fix reflog approxidate parsing bugJeff King2008-04-29
| | | | | | | | | | | | | | | | | | | In get_sha1_basic, we parse a string like HEAD@{10 seconds ago}:path/to/file into its constituent ref, reflog date, and path components. We never actually munge the string itself, but instead keep offsets into the string with their associated lengths. When we call approxidate on the contents inside braces, however, we pass just a string without a length. This means that approxidate could sometimes look past the closing brace and (erroneously) interpret the rest of the string as part of the date. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* rev-parse: fix meaning of rev~ vs rev~0.Linus Torvalds2008-03-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I think it would make more sense for rev~ to have the same guarantees that rev^ has, namely to always return a commit. I would also suggest that not giving a number would have the same effect of defaulting to 1, not 0. Right now it's a bit illogical, but at least it's an _undocumented_ illogical behaviour. This patch makes '^' and '~' act the same for the default count (i.e. both default to 1), and also have the same behaviour for a count of zero. Before (no discernible pattern): [torvalds@woody git]$ git rev-parse v1.5.1 v1.5.1^0 v1.5.1~0 v1.5.1^ v1.5.1~ 45354a57ee7e3e42c7137db6c94fa968c6babe8d 89815cab95268e8f0f58142b848ac4cd5e9cbdcb 45354a57ee7e3e42c7137db6c94fa968c6babe8d 045f5759c97746589a067461e50fad16f60711ac 45354a57ee7e3e42c7137db6c94fa968c6babe8d After (fairly logical): [torvalds@woody git]$ git rev-parse v1.5.1 v1.5.1^0 v1.5.1~0 v1.5.1^ v1.5.1~ 45354a57ee7e3e42c7137db6c94fa968c6babe8d 89815cab95268e8f0f58142b848ac4cd5e9cbdcb 89815cab95268e8f0f58142b848ac4cd5e9cbdcb 045f5759c97746589a067461e50fad16f60711ac 045f5759c97746589a067461e50fad16f60711ac Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'sp/refspec-match'Junio C Hamano2007-12-04
|\ | | | | | | | | | | | | | | * sp/refspec-match: refactor fetch's ref matching to use refname_match() push: use same rules as git-rev-parse to resolve refspecs add refname_match() push: support pushing HEAD to real branch name
| * add refname_match()Steffen Prohaska2007-11-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We use at least two rulesets for matching abbreviated refnames with full refnames (starting with 'refs/'). git-rev-parse and git-fetch use slightly different rules. This commit introduces a new function refname_match (const char *abbrev_name, const char *full_name, const char **rules). abbrev_name is expanded using the rules and matched against full_name. If a match is found the function returns true. rules is a NULL-terminate list of format patterns with "%.*s", for example: const char *ref_rev_parse_rules[] = { "%.*s", "refs/%.*s", "refs/tags/%.*s", "refs/heads/%.*s", "refs/remotes/%.*s", "refs/remotes/%.*s/HEAD", NULL }; Asterisks are included in the format strings because this is the form required in sha1_name.c. Sharing the list with the functions there is a good idea to avoid duplicating the rules. Hopefully this facilitates unified matching rules in the future. This commit makes the rules used by rev-parse for resolving refs to sha1s available for string comparison. Before this change, the rules were buried in get_sha1*() and dwim_ref(). A follow-up commit will refactor the rules used by fetch. refname_match() will be used for matching refspecs in git-send-pack. Thanks to Daniel Barkalow <barkalow@iabervon.org> for pointing out that ref_matches_abbrev in remote.c solves a similar problem and care should be taken to avoid confusion. Signed-off-by: Steffen Prohaska <prohaska@zib.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Allow ':/<oneline-prefix>' syntax to work with save_commit_buffer == 0Johannes Schindelin2007-12-03
|/ | | | | | | | | Earlier, ':/<oneline-prefix>' would not work (i.e. die) with commands that set save_commit_buffer = 0, such as blame, describe, pack-objects, reflog and bundle. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Make show_rfc2822_date() just another date output format.Junio C Hamano2007-07-13
| | | | | | | | | | | These days, show_date() takes a date_mode parameter to specify the output format, and a separate specialized function for dates in E-mails does not make much sense anymore. This retires show_rfc2822_date() function and make it just another date output format. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Active_nr is unsigned, hence can't be < 0Pierre Habouzit2007-06-08
| | | | | Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* rev-parse: Identify short sha1 sums correctly.James Bowes2007-05-29
| | | | | | | | find_short_packed_object was not loading the pack index files. Teach it to do so. Signed-off-by: James Bowes <jbowes@dangerouslyinc.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Attempt to delay prepare_alt_odb during get_sha1Shawn O. Pearce2007-05-26
| | | | | | | | | | | | | | | | Not every input value passed to get_sha1 is an abbreviated SHA-1. Its actually quite common for refs to be passed and for those refs to resolve to full SHA-1s, in which case we may not need to initialize the alternate object database list in this process. I'm relocating the call to prepare_alt_odb closer to the code that actually needs it to maintain the fix first introduced by Junio in 99a19b43 (to avoid ambiguous SHA-1 abbreviations from being accepted). This allows us to avoid the alt_odb list setup if we won't actually need it. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* add get_sha1_with_modeMartin Koegler2007-04-24
| | | | | | | | | | get_sha1_with_mode basically behaves as get_sha1. It has an additional parameter for storing the mode of the object. If the mode can not be determined, it stores S_IFINVALID. Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at> Signed-off-by: Junio C Hamano <junkio@cox.net>
* get rid of num_packed_objects()Nicolas Pitre2007-04-10
| | | | | | | | | | | | | The coming index format change doesn't allow for the number of objects to be determined from the size of the index file directly. Instead, Let's initialize a field in the packed_git structure with the object count when the index is validated since the count is always known at that point. While at it let's reorder some struct packed_git fields to avoid padding due to needed 64-bit alignment for some of them. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* clean up and optimize nth_packed_object_sha1() usageNicolas Pitre2007-04-05
| | | | | | | | | | | | | Let's avoid the open coded pack index reference in pack-object and use nth_packed_object_sha1() instead. This will help encapsulating index format differences in one place. And while at it there is no reason to copy SHA1's over and over while a direct pointer to it in the index will do just fine. Signed-off-by: Nicolas Pitre <nico@cam.org> Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Re-fix get_sha1_oneline()Linus Torvalds2007-03-12
| | | | | | | | What the function wants to return is not if we saw any return from pop_most_recent_commit(), but if we found what was asked for. Signed-off-by: Junio C Hamano <junkio@cox.net>
* I like the idea of the new ':/<oneline prefix>' notation, and gave itJim Meyering2007-03-11
| | | | | | | | | | | | | | | | | | a try, but all I could get was a segfault. It was dereferencing a NULL commit list. Fix below. With it, this example now works: $ mkdir .j; cd .j; touch f $ git-init; git-add f; git-commit -mc f; echo x >f; git-commit -md f $ git-diff -p :/c :/d diff --git a/f b/f index e69de29..587be6b 100644 --- a/f +++ b/f @@ -0,0 +1 @@ +x Signed-off-by: Jim Meyering <jim@meyering.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Use uint32_t for all packed object counts.Shawn O. Pearce2007-03-07
| | | | | | | | | | | | | As we permit up to 2^32-1 objects in a single packfile we cannot use a signed int to represent the object offset within a packfile, after 2^31-1 objects we will start seeing negative indexes and error out or compute bad addresses within the mmap'd index. This is a minor cleanup that does not introduce any significant logic changes. It is roach free. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* object name: introduce ':/<oneline prefix>' notationJohannes Schindelin2007-02-24
| | | | | | | | | | | | | | | | | | | To name a commit, you can now say $ git rev-parse ':/Initial revision of "git"' and it will return the hash of the youngest commit whose commit message (the oneline) begins with the given prefix. For future extension, a leading exclamation mark is treated specially: if you want to match a commit message starting with a '!', just repeat the exclamation mark. So, to match a commit which starts with '!Hello World', use $ git show ':/!!Hello World' Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* reflog: handle $name => remotes/%s/HEAD mapping consistently for logsJunio C Hamano2007-02-08
| | | | | | | | | | When refs/remotes/gfi/master and refs/remotes/gfi/HEAD exist, and the latter is a symref that points at the former, dwim_ref() resolves string "gfi" to "refs/remotes/gfi/master" as expected, but dwim_log() does not understand "gfi@{1.day}" and needs to be told "gfi/master@{1.day}". This is confusing. Signed-off-by: Junio C Hamano <junkio@cox.net>
* log --reflog: use dwim_logJohannes Schindelin2007-02-08
| | | | | | | | | Since "git log origin/master" uses dwim_log() to match "refs/remotes/origin/master", it makes sense to do that for "git log --reflog", too. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Enable HEAD@{...} and make it independent from the current branchNicolas Pitre2007-02-03
| | | | | Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* provide a nice @{...} syntax to always mean the current branch reflogNicolas Pitre2007-02-01
| | | | | | | | This is shorter than HEAD@{...} and being nameless it has no semantic issues. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* prevent HEAD reflog to be interpreted as current branch reflogNicolas Pitre2007-02-01
| | | | | | | | | | | The work in progress to enable separate reflog for HEAD will make it independent from reflog of any branch HEAD might be pointing to. In the mean time disallow HEAD@{...} until that work is completed. Otherwise people might get used to the current behavior which makes HEAD@{...} an alias for <current_branch>@{...} which won't be the case later. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Extend read_ref_at() to be usable from places other than sha1_name.Junio C Hamano2007-01-19
| | | | | | | | | | | | | You can pass an extra argument to the function to receive the reflog message information. Also when the log does not go back beyond the point the user asked, the cut-off time and count are given back to the caller for emitting the error messages as appropriately. We could later add configuration for get_sha1_basic() to make it an error instead of it being just a warning. Signed-off-by: Junio C Hamano <junkio@cox.net>
* dwim_ref(): Separate name-to-ref DWIM code out.Junio C Hamano2007-01-19
| | | | | | | I'll be using this in another function to figure out what to pass to resolve_ref(). Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'lj/refs'Junio C Hamano2006-11-01
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lj/refs: (63 commits) Fix show-ref usagestring t3200: git-branch testsuite update sha1_name.c: avoid compilation warnings. Make git-branch a builtin ref-log: fix D/F conflict coming from deleted refs. git-revert with conflicts to behave as git-merge with conflicts core.logallrefupdates thinko-fix git-pack-refs --all core.logallrefupdates create new log file only for branch heads. Remove bashism from t3210-pack-refs.sh ref-log: allow ref@{count} syntax. pack-refs: call fflush before fsync. pack-refs: use lockfile as everybody else does. git-fetch: do not look into $GIT_DIR/refs to see if a tag exists. lock_ref_sha1_basic does not remove empty directories on BSD Do not create tag leading directories since git update-ref does it. Check that a tag exists using show-ref instead of looking for the ref file. Use git-update-ref to delete a tag instead of rm()ing the ref file. Fix refs.c;:repack_without_ref() clean-up path Clean up "git-branch.sh" and add remove recursive dir test cases. ...
| * sha1_name.c: avoid compilation warnings.Junio C Hamano2006-10-23
| | | | | | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
| * ref-log: allow ref@{count} syntax.Junio C Hamano2006-10-05
| | | | | | | | | | | | | | | | | | | | | | | | Often I find myself wanting to say 'tip of "next" before I merged the last three topics'. Now I can say that with: git log next@{3}..next Since small integers alone are invalid input strings to approxidate, there is no fear of confusion. Signed-off-by: Junio C Hamano <junkio@cox.net>
| * Merge branch 'master' into lj/refsJunio C Hamano2006-09-27
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (72 commits) runstatus: do not recurse into subdirectories if not needed grep: fix --fixed-strings combined with expression. grep: free expressions and patterns when done. Corrected copy-and-paste thinko in ignore executable bit test case. An illustration of rev-list --parents --pretty=raw Allow git-checkout when on a non-existant branch. gitweb: Decode long title for link tooltips git-svn: Fix fetch --no-ignore-externals with GIT_SVN_NO_LIB=1 Ignore executable bit when adding files if filemode=0. Remove empty ref directories that prevent creating a ref. Use const for interpolate arguments git-archive: update documentation Deprecate merge-recursive.py gitweb: fix over-eager application of esc_html(). Allow '(no author)' in git-svn's authors file. Allow 'svn fetch' on '(no date)' revisions in Subversion. git-repack: allow git-repack to run in subdirectory Remove upload-tar and make git-tar-tree a thin wrapper to git-archive git-tar-tree: Move code for git-archive --format=tar to archive-tar.c git-tar-tree: Remove duplicate git_config() call ...
| * | Tell between packed, unpacked and symbolic refs.Junio C Hamano2006-09-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a "int *flag" parameter to resolve_ref() and makes for_each_ref() family to call callback function with an extra "int flag" parameter. They are used to give two bits of information (REF_ISSYMREF and REF_ISPACKED) about the ref. Signed-off-by: Junio C Hamano <junkio@cox.net>
| * | Make ref resolution sanerLinus Torvalds2006-09-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old code used to totally mix up the notion of a ref-name and the path that that ref was associated with. That was not only horribly ugly (a number of users got the path, and then wanted to try to turn it back into a ref-name again), but it fundamnetally doesn't work at all once we do any setup where a ref doesn't have a 1:1 relationship with a particular pathname. This fixes things up so that we use the ref-name throughout, and only turn it into a pathname once we actually look it up in the filesystem. That makes a lot of things much clearer and more straightforward. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | | Reject hexstring longer than 40-bytes in get_short_sha1()pclouds@gmail.com2006-10-18
| |/ |/| | | | | | | | | | | Such a string can never be a valid object name. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | sha1_name.c: understand "describe" output as a valid object nameJunio C Hamano2006-09-20
|/ | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* Replace uses of strdup with xstrdup.Shawn Pearce2006-09-02
| | | | | | | | | | | | | | | | Like xmalloc and xrealloc xstrdup dies with a useful message if the native strdup() implementation returns NULL rather than a valid pointer. I just tried to use xstrdup in new code and found it to be missing. However I expected it to be present as xmalloc and xrealloc are already commonly used throughout the code. [jc: removed the part that deals with last_XXX, which I am finding more and more dubious these days.] Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Convert memset(hash,0,20) to hashclr(hash).Junio C Hamano2006-08-23
| | | | | | In the same spirit as hashcmp() and hashcpy(). Signed-off-by: Junio C Hamano <junkio@cox.net>
* Convert memcpy(a,b,20) to hashcpy(a,b).Shawn Pearce2006-08-23
| | | | | | | | | | | | | | | | | | | | | | | This abstracts away the size of the hash values when copying them from memory location to memory location, much as the introduction of hashcmp abstracted away hash value comparsion. A few call sites were using char* rather than unsigned char* so I added the cast rather than open hashcpy to be void*. This is a reasonable tradeoff as most call sites already use unsigned char* and the existing hashcmp is also declared to be unsigned char*. [jc: Splitted the patch to "master" part, to be followed by a patch for merge-recursive.c which is not in "master" yet. Fixed the cast in the latter hunk to combine-diff.c which was wrong in the original. Also converted ones left-over in combine-diff.c, diff-lib.c and upload-pack.c ] Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Do not use memcmp(sha1_1, sha1_2, 20) with hardcoded length.David Rientjes2006-08-17
| | | | | | | | | | | | | Introduces global inline: hashcmp(const unsigned char *sha1, const unsigned char *sha2) Uses memcmp for comparison and returns the result based on the length of the hash name (a future runtime decision). Acked-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* make inline is_null_sha1 globalDavid Rientjes2006-08-15
| | | | | | | | | | Replace sha1 comparisons to null_sha1 with a global inline (which previously an unused static inline in builtin-apply.c) [jc: with a fix from Jonas Fonseca.] Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* find_unique_abbrev() with len=0 should not abbreviateJunio C Hamano2006-08-09
| | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* Remove TYPE_* constant macros and use object_type enums consistently.Linus Torvalds2006-07-12
| | | | | | | | | | | | | | | This updates the type-enumeration constants introduced to reduce the memory footprint of "struct object" to match the type bits already used in the packfile format, by removing the former (i.e. TYPE_* constant macros) and using the latter (i.e. enum object_type) throughout the code for consistency. Eventually we can stop passing around the "type strings" entirely, and this will help - no confusion about two different integer enumeration. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Rename safe_strncpy() to strlcpy().Peter Eriksen2006-06-24
| | | | | | | | | | | This cleans up the use of safe_strncpy() even more. Since it has the same semantics as strlcpy() use this name instead. Also move the definition from inside path.c to its own file compat/strlcpy.c, and use it conditionally at compile time, since some platforms already has strlcpy(). It's included in the same way as compat/setenv.c. Signed-off-by: Peter Eriksen <s022018@student.dtu.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Shrink "struct object" a bitLinus Torvalds2006-06-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This shrinks "struct object" by a small amount, by getting rid of the "struct type *" pointer and replacing it with a 3-bit bitfield instead. In addition, we merge the bitfields and the "flags" field, which incidentally should also remove a useless 4-byte padding from the object when in 64-bit mode. Now, our "struct object" is still too damn large, but it's now less obviously bloated, and of the remaining fields, only the "util" (which is not used by most things) is clearly something that should be eventually discarded. This shrinks the "git-rev-list --all" memory use by about 2.5% on the kernel archive (and, perhaps more importantly, on the larger mozilla archive). That may not sound like much, but I suspect it's more on a 64-bit platform. There are other remaining inefficiencies (the parent lists, for example, probably have horrible malloc overhead), but this was pretty obvious. Most of the patch is just changing the comparison of the "type" pointer from one of the constant string pointers to the appropriate new TYPE_xxx small integer constant. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Implement safe_strncpy() as strlcpy() and use it more.Peter Eriksen2006-06-16
| | | | | Signed-off-by: Peter Eriksen <s022018@student.dtu.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Change 'master@noon' syntax to 'master@{noon}'.Shawn Pearce2006-05-19
| | | | | | | | | | | Its ambiguous to parse "master@2006-05-17 18:30:foo" when foo is meant as a file name and ":30" is meant as 30 minutes past 6 pm. Therefore all date specifications in a sha1 expression must now appear within brackets and the ':' splitter used for the path name in a sha1 expression ignores ':' appearing within brackets. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Fix ref log parsing so it works properly.Shawn Pearce2006-05-17
| | | | | | | | | The log parser was only ever matching the last log record due to calling strtoul on "> 1136091609" rather than " 1136091609". Also once a match for '@' has been found after the name of the ref there is no point in looking for another '@' within the remaining text. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Support 'master@2 hours ago' syntaxShawn Pearce2006-05-17
| | | | | | | | | | | Extended sha1 expressions may now include date specifications which indicate a point in time within the local repository's history. If the ref indicated to the left of '@' has a log in $GIT_DIR/logs/<ref> then the value of the ref at the time indicated by the specification is obtained from the ref's log. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* get_sha1() - fix infinite loop on nonexistent stage.Junio C Hamano2006-05-08
| | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* get_sha1(): :path and :[0-3]:path to extract from index.Junio C Hamano2006-04-30
| | | | | | | | | Earlier patch to say <ent>:<path> by Linus was very useful, and this extends the same idea to the current index. An sha1 expression :<path> extracts the object name for the named path from the current index. Signed-off-by: Junio C Hamano <junkio@cox.net>
* get_tree_entry(): make it available from tree-walkJunio C Hamano2006-04-19
| | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* sha1_name.c: no need to include diff.h; tree-walk.h will do.Junio C Hamano2006-04-19
| | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* sha1_name.c: prepare to make get_tree_entry() reusable from others.Junio C Hamano2006-04-19
| | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* get_sha1() shorthands for blob/tree objectsLinus Torvalds2006-04-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a fairly straightforward patch to allow "get_sha1()" to also have shorthands for tree and blob objects. The syntax is very simple and intuitive: you can specify a tree or a blob by simply specifying <revision>:<path>, and get_sha1() will do the SHA1 lookup from the tree for you. You can currently do it with "git ls-tree <rev> <path>" and parsing the output, but that's actually pretty awkward. With this, you can do something like git cat-file blob v1.2.4:Makefile to get the contents of "Makefile" at revision v1.2.4. Now, this isn't necessarily something you really need all that often, but the concept itself is actually pretty powerful. We could, for example, allow things like git diff v0.99.6:git-commit-script..v1.3.0:git-commit.sh to see the difference between two arbitrary files in two arbitrary revisions. To do that, the only thing we'd have to do is to make git-diff-tree accept two blobs to diff, in addition to the two trees it now expects. Signed-off-by: Junio C Hamano <junkio@cox.net>