summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cb85bfe)
raw | patch | inline | side by side (parent: cb85bfe)
author | Eric Wong <normalperson@yhbt.net> | |
Tue, 7 Mar 2006 19:59:17 +0000 (11:59 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 17 Mar 2006 22:10:24 +0000 (14:10 -0800) |
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Documentation/git-ls-files.txt | patch | blob | history | |
ls-files.c | patch | blob | history |
index e813f8420275f5b95810646c2a43c35f57a5ba70..59f6adc494ded75e9fa4dceb57b4db65dfa229a5 100644 (file)
(-[c|d|o|i|s|u|k|m])\*
[-x <pattern>|--exclude=<pattern>]
[-X <file>|--exclude-from=<file>]
- [--exclude-per-directory=<file>]
+ [--exclude-per-directory=<file>]
[--error-unmatch]
- [--full-name] [--] [<file>]\*
+ [--full-name] [--abbrev] [--] [<file>]\*
DESCRIPTION
-----------
option forces paths to be output relative to the project
top directory.
+--abbrev[=<n>]::
+ Instead of showing the full 40-byte hexadecimal object
+ lines, show only handful hexdigits prefix.
+ Non default number of digits can be specified with --abbrev=<n>.
+
--::
Do not interpret any more arguments as options.
diff --git a/ls-files.c b/ls-files.c
index df25c8c012a96a8277413ca3a81490b81b7dc067..585f6a7ff2aa4f3bf6c9273bd6f87a2fb37ab64a 100644 (file)
--- a/ls-files.c
+++ b/ls-files.c
#include "cache.h"
#include "quote.h"
+static int abbrev = 0;
static int show_deleted = 0;
static int show_cached = 0;
static int show_others = 0;
printf("%s%06o %s %d\t",
tag,
ntohl(ce->ce_mode),
- sha1_to_hex(ce->sha1),
+ abbrev ? find_unique_abbrev(ce->sha1,abbrev)
+ : sha1_to_hex(ce->sha1),
ce_stage(ce));
write_name_quoted("", 0, ce->name + offset,
line_terminator, stdout);
static const char ls_files_usage[] =
"git-ls-files [-z] [-t] [-v] (--[cached|deleted|others|stage|unmerged|killed|modified])* "
"[ --ignored ] [--exclude=<pattern>] [--exclude-from=<file>] "
- "[ --exclude-per-directory=<filename> ] [--full-name] [--] [<file>]*";
+ "[ --exclude-per-directory=<filename> ] [--full-name] [--abbrev] "
+ "[--] [<file>]*";
int main(int argc, const char **argv)
{
error_unmatch = 1;
continue;
}
+ if (!strncmp(arg, "--abbrev=", 9)) {
+ abbrev = strtoul(arg+9, NULL, 10);
+ if (abbrev && abbrev < MINIMUM_ABBREV)
+ abbrev = MINIMUM_ABBREV;
+ else if (abbrev > 40)
+ abbrev = 40;
+ continue;
+ }
+ if (!strcmp(arg, "--abbrev")) {
+ abbrev = DEFAULT_ABBREV;
+ continue;
+ }
if (*arg == '-')
usage(ls_files_usage);
break;