summaryrefslogtreecommitdiff
path: root/sha1_name.c
AgeCommit message (Collapse)Author
2007-07-14Make show_rfc2822_date() just another date output format.Junio C Hamano
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>
2007-06-08Active_nr is unsigned, hence can't be < 0Pierre Habouzit
Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-05-30rev-parse: Identify short sha1 sums correctly.James Bowes
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>
2007-05-27Attempt to delay prepare_alt_odb during get_sha1Shawn O. Pearce
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>
2007-04-24add get_sha1_with_modeMartin Koegler
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>
2007-04-10get rid of num_packed_objects()Nicolas Pitre
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>
2007-04-05clean up and optimize nth_packed_object_sha1() usageNicolas Pitre
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>
2007-03-12Re-fix get_sha1_oneline()Linus Torvalds
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>
2007-03-11I like the idea of the new ':/<oneline prefix>' notation, and gave itJim Meyering
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>
2007-03-07Use uint32_t for all packed object counts.Shawn O. Pearce
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>
2007-02-24object name: introduce ':/<oneline prefix>' notationJohannes Schindelin
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>
2007-02-09reflog: handle $name => remotes/%s/HEAD mapping consistently for logsJunio C Hamano
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>
2007-02-09log --reflog: use dwim_logJohannes Schindelin
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>
2007-02-04Enable HEAD@{...} and make it independent from the current branchNicolas Pitre
Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-02provide a nice @{...} syntax to always mean the current branch reflogNicolas Pitre
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>
2007-02-02prevent HEAD reflog to be interpreted as current branch reflogNicolas Pitre
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>
2007-01-20Extend read_ref_at() to be usable from places other than sha1_name.Junio C Hamano
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>
2007-01-20dwim_ref(): Separate name-to-ref DWIM code out.Junio C Hamano
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>
2006-11-01Merge branch 'lj/refs'Junio C Hamano
* 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. ...
2006-10-24sha1_name.c: avoid compilation warnings.Junio C Hamano
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-19Reject hexstring longer than 40-bytes in get_short_sha1()pclouds@gmail.com
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>
2006-10-06ref-log: allow ref@{count} syntax.Junio C Hamano
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>
2006-09-28Merge branch 'master' into lj/refsJunio C Hamano
* 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 ...
2006-09-21Tell between packed, unpacked and symbolic refs.Junio C Hamano
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>
2006-09-20sha1_name.c: understand "describe" output as a valid object nameJunio C Hamano
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-18Make ref resolution sanerLinus Torvalds
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>
2006-09-02Replace uses of strdup with xstrdup.Shawn Pearce
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>
2006-08-23Convert memset(hash,0,20) to hashclr(hash).Junio C Hamano
In the same spirit as hashcmp() and hashcpy(). Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-23Convert memcpy(a,b,20) to hashcpy(a,b).Shawn Pearce
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>
2006-08-17Do not use memcmp(sha1_1, sha1_2, 20) with hardcoded length.David Rientjes
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>
2006-08-15make inline is_null_sha1 globalDavid Rientjes
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>
2006-08-09find_unique_abbrev() with len=0 should not abbreviateJunio C Hamano
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-13Remove TYPE_* constant macros and use object_type enums consistently.Linus Torvalds
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>
2006-06-25Rename safe_strncpy() to strlcpy().Peter Eriksen
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>
2006-06-18Shrink "struct object" a bitLinus Torvalds
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>
2006-06-17Implement safe_strncpy() as strlcpy() and use it more.Peter Eriksen
Signed-off-by: Peter Eriksen <s022018@student.dtu.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-19Change 'master@noon' syntax to 'master@{noon}'.Shawn Pearce
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>
2006-05-18Fix ref log parsing so it works properly.Shawn Pearce
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>
2006-05-18Support 'master@2 hours ago' syntaxShawn Pearce
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>
2006-05-08get_sha1() - fix infinite loop on nonexistent stage.Junio C Hamano
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-01get_sha1(): :path and :[0-3]:path to extract from index.Junio C Hamano
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>
2006-04-19get_tree_entry(): make it available from tree-walkJunio C Hamano
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-19sha1_name.c: no need to include diff.h; tree-walk.h will do.Junio C Hamano
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-19sha1_name.c: prepare to make get_tree_entry() reusable from others.Junio C Hamano
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-19get_sha1() shorthands for blob/tree objectsLinus Torvalds
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>
2006-03-24sha1_name: warning ambiguous refs.Junio C Hamano
This makes sure that many commands that take refs on the command line to honor core.warnambiguousrefs configuration. Earlier, the commands affected by this patch did not read the configuration file. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-21get_sha1_basic(): try refs/... and finally refs/remotes/$foo/HEADJunio C Hamano
This implements the suggestion by Jeff King to use refs/remotes/$foo/HEAD to interpret a shorthand "$foo" to mean the primary branch head of a tracked remote. clone needs to be told about this convention as well. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-21core.warnambiguousrefs: warns when "name" is used and both "name" branch and ↵Junio C Hamano
tag exists. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-10find_unique_abbrev() simplification.Junio C Hamano
Earlier it did not grok the 0{40} SHA1 very well, but what it needed to do was to find the shortest 0{N} that is not used as a valid object name to be consistent with the way names of valid objects are abbreviated. This makes some users simpler. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-03get_sha1_1: allow octopus^12 to be properly parsed.Junio C Hamano
We probably thought anybody who does more than 9 parents in an Octopus is insane when this was initially done, but there is no inherent reason to limit the number of independent topic branches that happen to mature at the same time. Our commit-tree allows up to 16 already, so at least we should prepare to handle what we can produce, if only to be consistent. Signed-off-by: Junio C Hamano <junkio@cox.net>