Staging
v0.5.1
Revision 4e27fb06f0fe4206606172f94a18e08d7d87c070 authored by Nicolas Pitre on 06 October 2006, 19:39:09 UTC, committed by Junio C Hamano on 10 October 2006, 03:23:09 UTC
This patch does 3 things:

1) Output the number of commits along with the name for each author
   (nice to know for long lists spending more than a screen worth of
   commit lines).

2) Provide a switch (-n) to sort authors according to their number of
   commits instead of author alphabetic order.

3) Provide a switch (-s) to supress commit lines and only keep a
   summary of authors and the number of commits for each of them.

And for good measure a short usage is displayed with -h.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 96779be
Raw File
builtin-symbolic-ref.c
#include "builtin.h"
#include "cache.h"

static const char git_symbolic_ref_usage[] =
"git-symbolic-ref name [ref]";

static void check_symref(const char *HEAD)
{
	unsigned char sha1[20];
	const char *git_HEAD = xstrdup(git_path("%s", HEAD));
	const char *git_refs_heads_master = resolve_ref(git_HEAD, sha1, 0);
	if (git_refs_heads_master) {
		/* we want to strip the .git/ part */
		int pfxlen = strlen(git_HEAD) - strlen(HEAD);
		puts(git_refs_heads_master + pfxlen);
	}
	else
		die("No such ref: %s", HEAD);
}

int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
{
	git_config(git_default_config);
	switch (argc) {
	case 2:
		check_symref(argv[1]);
		break;
	case 3:
		create_symref(xstrdup(git_path("%s", argv[1])), argv[2]);
		break;
	default:
		usage(git_symbolic_ref_usage);
	}
	return 0;
}
back to top