# [PATCH] submodule: remove a superfluous second check for the "new" variable

3 messages from 2017-04-17 to 2017-04-17. Participants: Sebastian Schuberth, Stefan Beller.
Thread: https://gitlist.dev/t/45717

## Sebastian Schuberth, 2017-04-17 07:59

Subject: [PATCH] submodule: remove a superfluous second check for the "new" variable
Message-ID: <0102015b7aecbf67-2f63e58b-5f75-4c9b-975f-e8e35176d510-000000@eu-west-1.amazonses.com>
URL: https://gitlist.dev/e/0102015b7aecbf67-2f63e58b-5f75-4c9b-975f-e8e35176d510-000000%40eu-west-1.amazonses.com

```
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
---
 submodule.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/submodule.c b/submodule.c
index c52d663..68623bd 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1396,8 +1396,7 @@ int submodule_move_head(const char *path,
 			cp1.no_stdin = 1;
 			cp1.dir = path;
 
-			argv_array_pushl(&cp1.args, "update-ref", "HEAD",
-					 new ? new : EMPTY_TREE_SHA1_HEX, NULL);
+			argv_array_pushl(&cp1.args, "update-ref", "HEAD", new, NULL);
 
 			if (run_command(&cp1)) {
 				ret = -1;

--
https://github.com/git/git/pull/345

```

## Stefan Beller, 2017-04-17 18:02

Subject: Re: [PATCH] submodule: remove a superfluous second check for the "new" variable
Message-ID: <CAGZ79kb01g0AoD0b+ysqd-H049BAX-j0om2pwPqXA7fXhX2Y8w@mail.gmail.com>
URL: https://gitlist.dev/e/CAGZ79kb01g0AoD0b%2Bysqd-H049BAX-j0om2pwPqXA7fXhX2Y8w%40mail.gmail.com
In-Reply-To: <0102015b7aecbf67-2f63e58b-5f75-4c9b-975f-e8e35176d510-000000@eu-west-1.amazonses.com>

```
On Mon, Apr 17, 2017 at 12:59 AM, Sebastian Schuberth
<sschuberth@gmail.com> wrote:
> Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
> ---
>  submodule.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/submodule.c b/submodule.c
> index c52d663..68623bd 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -1396,8 +1396,7 @@ int submodule_move_head(const char *path,
>                         cp1.no_stdin = 1;
>                         cp1.dir = path;
>
> -                       argv_array_pushl(&cp1.args, "update-ref", "HEAD",
> -                                        new ? new : EMPTY_TREE_SHA1_HEX, NULL);
> +                       argv_array_pushl(&cp1.args, "update-ref", "HEAD", new, NULL);

EMPTY_TREE_SHA1_HEX != NULL?

Can you clarify the intent in the commit message?

Thanks,
Stefan

```

## Sebastian Schuberth, 2017-04-17 18:21

Subject: Re: [PATCH] submodule: remove a superfluous second check for the "new" variable
Message-ID: <be511659-83fb-9b34-0ce8-8f6c21b91143@gmail.com>
URL: https://gitlist.dev/e/be511659-83fb-9b34-0ce8-8f6c21b91143%40gmail.com
In-Reply-To: <CAGZ79kb01g0AoD0b+ysqd-H049BAX-j0om2pwPqXA7fXhX2Y8w@mail.gmail.com>

```
On 2017-04-17 20:02, Stefan Beller wrote:

>> diff --git a/submodule.c b/submodule.c
>> index c52d663..68623bd 100644
>> --- a/submodule.c
>> +++ b/submodule.c
>> @@ -1396,8 +1396,7 @@ int submodule_move_head(const char *path,
>>                          cp1.no_stdin = 1;
>>                          cp1.dir = path;
>>
>> -                       argv_array_pushl(&cp1.args, "update-ref", "HEAD",
>> -                                        new ? new : EMPTY_TREE_SHA1_HEX, NULL);
>> +                       argv_array_pushl(&cp1.args, "update-ref", "HEAD", new, NULL);
> 
> EMPTY_TREE_SHA1_HEX != NULL?
> 
> Can you clarify the intent in the commit message?

Sure. A few lines up (3 lines out of the diff) we have "if (new) {" [1], thus there's no need to check "new != NULL" here again.

[1] https://github.com/git/git/pull/345/files#diff-471db3ea6697763218bb8335a95ece57R1392

-- 
Sebastian Schuberth

```
