Skip to content

Commit 4478a47

Browse files
committed
psuh: display the top of origin/master
Signed-off-by: Long Nguyen <n.h.long.9697@gmail.com>
1 parent 4e183e2 commit 4478a47

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

builtin/psuh.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,23 @@
22
#include "gettext.h"
33
#include "config.h"
44
#include "repository.h"
5+
#include "environment.h"
6+
#include "wt-status.h"
7+
#include "commit.h"
8+
#include "pretty.h"
9+
#include "strbuf.h"
510

611
int cmd_psuh(int argc, const char **argv,
712
const char *prefix, struct repository *repo) {
813
int i;
914
const char *config_name;
15+
struct wt_status status;
16+
struct commit *c = NULL;
17+
struct strbuf commitline = STRBUF_INIT;
18+
19+
wt_status_prepare(repo, &status);
20+
repo_config(repo, git_default_config, &status);
21+
1022
printf(Q_("Your args (there is %d):\n",
1123
"Your args (there are %d):\n",
1224
argc),
@@ -24,5 +36,15 @@ int cmd_psuh(int argc, const char **argv,
2436
else
2537
printf(_("Your name: %s\n"), config_name);
2638

39+
printf(_("Your current branch: %s\n"), status.branch);
40+
41+
c = lookup_commit_reference_by_name("origin/master");
42+
43+
if (c != NULL) {
44+
pp_commit_easy(CMIT_FMT_ONELINE, c, &commitline);
45+
printf(_("Current commit: %s\n"), commitline.buf);
46+
}
47+
48+
2749
return 0;
2850
}

0 commit comments

Comments
 (0)