All of lore.kernel.org
 help / color / mirror / Atom feed
From: Slavica Djukic <slavicadj.ip2018@gmail.com>
To: slavicadj.ip2018@gmail.com
Cc: Johannes.Schindelin@gmx.de, git@vger.kernel.org, slawica92@hotmail.com
Subject: [PATCH 2/3] [Outreachy] ident: introduce set_fallback_ident() function
Date: Thu,  1 Nov 2018 13:00:29 +0100	[thread overview]
Message-ID: <20181101120029.13992-1-slawica92@hotmail.com> (raw)
In-Reply-To: <20181101115546.13516-1-slawica92@hotmail.com>

Usually, when creating a commit, ident is needed to record the author
and commiter.
But, when there is commit not intended to published, e.g. when stashing
changes,  valid ident is not necessary.
To allow creating commits in such scenario, let's introduce helper
function "set_fallback_ident(), which will pre-load the ident.

In following commit, set_fallback_ident() function will be called in stash.

Signed-off-by: Slavica Djukic <slawica92@hotmail.com>
---
 cache.h |  1 +
 ident.c | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/cache.h b/cache.h
index 681307f716..6b5b559a05 100644
--- a/cache.h
+++ b/cache.h
@@ -1470,6 +1470,7 @@ extern const char *git_sequence_editor(void);
 extern const char *git_pager(int stdout_is_tty);
 extern int is_terminal_dumb(void);
 extern int git_ident_config(const char *, const char *, void *);
+void set_fallback_ident(const char *name, const char *email);
 extern void reset_ident_date(void);
 
 struct ident_split {
diff --git a/ident.c b/ident.c
index 33bcf40644..410bd495e9 100644
--- a/ident.c
+++ b/ident.c
@@ -505,6 +505,23 @@ int git_ident_config(const char *var, const char *value, void *data)
 	return 0;
 }
 
+void set_fallback_ident(const char *name, const char *email)
+{
+	if (!git_default_name.len) {
+		strbuf_addstr(&git_default_name, name);
+		committer_ident_explicitly_given |= IDENT_NAME_GIVEN;
+		author_ident_explicitly_given |= IDENT_NAME_GIVEN;
+		ident_config_given |= IDENT_NAME_GIVEN;
+	}
+
+	if (!git_default_email.len) {
+		strbuf_addstr(&git_default_email, email);
+		committer_ident_explicitly_given |= IDENT_MAIL_GIVEN;
+		author_ident_explicitly_given |= IDENT_MAIL_GIVEN;
+		ident_config_given |= IDENT_MAIL_GIVEN;
+	}
+}
+
 static int buf_cmp(const char *a_begin, const char *a_end,
 		   const char *b_begin, const char *b_end)
 {
-- 
2.19.1.windows.1


  parent reply	other threads:[~2018-11-01 12:00 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-23 16:29 [PATCH 1/3] [Outreachy] t3903-stash: test without configured user name Slavica
2018-10-23 18:52 ` Christian Couder
2018-10-24 13:56   ` Slavica
2018-10-25  4:44     ` Junio C Hamano
2018-10-23 19:19 ` Eric Sunshine
2018-10-24  2:48 ` Junio C Hamano
2018-10-24  7:39   ` Johannes Schindelin
2018-10-24  9:58     ` Junio C Hamano
2018-10-24 15:18       ` Johannes Schindelin
2018-10-25  4:17         ` Junio C Hamano
2018-10-24 20:01 ` [PATCH v2 " Slavica Djukic
2018-10-24 20:05   ` Slavica Djukic
2018-10-24 20:25     ` Eric Sunshine
2018-10-25  4:48       ` Junio C Hamano
2018-10-25 19:13   ` [PATCH v3 " Slavica Djukic
2018-10-25 19:20     ` Slavica Djukic
2018-10-26  1:13       ` Junio C Hamano
2018-10-30 13:04         ` Slavica Djukic
2018-11-01 11:55       ` [PATCH 0/3] [Outreachy] make stash work if user.name and user.email are not configured Slavica Djukic
2018-11-01 11:58         ` [PATCH 1/3][Outreachy] t3903-stash: test without configured user.name and user.email Slavica Djukic
2018-11-01 14:53           ` Christian Couder
2018-11-02  4:59           ` [PATCH 2+3/3] stash: tolerate missing user identity Junio C Hamano
2018-11-01 12:00         ` Slavica Djukic [this message]
2018-11-02  3:01           ` [PATCH 2/3] [Outreachy] ident: introduce set_fallback_ident() function Junio C Hamano
2018-11-02  4:41             ` Junio C Hamano
2018-11-02  5:22               ` Junio C Hamano
2018-11-01 12:02         ` [PATCH 3/3] [Outreachy] stash: use " Slavica Djukic
2018-11-14 22:12         ` [PATCH v2 0/2] [Outreachy] make stash work if user.name and user.email are not configured Slavica Djukic
2018-11-14 22:25           ` [PATCH v2 1/2] [Outreachy] t3903-stash: test without configured user.name and user.email Slavica Djukic
2018-11-15 12:37             ` Johannes Schindelin
2018-11-16  5:55             ` Junio C Hamano
2018-11-16  6:26               ` Junio C Hamano
2018-11-16  6:32               ` Junio C Hamano
2018-11-16  8:28               ` Slavica Djukic
2018-11-16 10:12                 ` Junio C Hamano
2018-11-17 18:47                   ` Slavica Djukic
2018-11-18  6:28                     ` Junio C Hamano
2018-11-14 22:28           ` [PATCH v2 2/2] [Outreachy] stash: tolerate missing user identity Slavica Djukic
2018-11-16  5:35             ` Junio C Hamano
2018-11-18 13:29           ` [PATCH 0/1 v3] make stash work if user.name and user.email are not configured Slavica Djukic
2018-11-18 13:44             ` [PATCH 1/1 v3] stash: tolerate missing user identity Slavica Djukic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181101120029.13992-1-slawica92@hotmail.com \
    --to=slavicadj.ip2018@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=slawica92@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.