Skip to content

Commit f120a72

Browse files
Merge pull request git-for-windows#434: Integrate git update-microsoft-git with apt-get
Extend the `git update-microsoft-git` builtin to call `apt-get` in a similar way we do `brew` on macOS.
2 parents 3011dc5 + fd0d1f3 commit f120a72

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,15 @@ git version
101101
scalar version
102102
```
103103

104-
To upgrade microsoft/git, you can run the necessary `brew` commands:
104+
To upgrade `microsoft/git`, you can run the necessary `brew` commands:
105105

106106
```shell
107107
brew update
108108
brew upgrade --cask microsoft-git
109109
```
110110

111-
Or you can run the `git update-microsoft-git` command, which will run those brew commands for you.
111+
Or you can run the `git update-microsoft-git` command, which will run those
112+
`brew` commands for you.
112113

113114
## Linux
114115

@@ -125,6 +126,16 @@ sudo apt-get update
125126
sudo apt-get install microsoft-git
126127
```
127128

129+
To upgrade `microsoft/git`, you can run the necessary `apt-get` commands:
130+
131+
```shell
132+
sudo apt-get update
133+
sudo apt-get upgrade microsoft-git
134+
```
135+
136+
Or you can run the `git update-microsoft-git` command, which will run those
137+
`apt-get` commands for you.
138+
128139
### Ubuntu 21.04 (Hirsute)
129140

130141
```shell
@@ -134,6 +145,16 @@ sudo apt-get update
134145
sudo apt-get install microsoft-git
135146
```
136147

148+
To upgrade `microsoft/git`, you can run the necessary `apt-get` commands:
149+
150+
```shell
151+
sudo apt-get update
152+
sudo apt-get upgrade microsoft-git
153+
```
154+
155+
Or you can run the `git update-microsoft-git` command, which will run those
156+
`apt-get` commands for you.
157+
137158
### Other Ubuntu/Debian distributions
138159

139160
Please use the most recent
@@ -152,7 +173,11 @@ which should have the same output:
152173
git version
153174
scalar version
154175
```
176+
177+
To upgrade, you will need to repeat these steps to reinstall.
178+
155179
### Non-Ubuntu/Debian distributions
180+
156181
You will need to compile and install `microsoft/git` from source:
157182

158183
```shell

builtin/update-microsoft-git.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,26 @@ static int platform_specific_upgrade(void)
5656
#else
5757
static int platform_specific_upgrade(void)
5858
{
59-
error(_("update-microsoft-git is not supported on this platform"));
60-
return 1;
59+
int res;
60+
struct strvec args = STRVEC_INIT;
61+
62+
printf("Updating apt-get with 'sudo apt-get update'\n\n");
63+
64+
strvec_pushl(&args, "sudo", "apt-get", "update", NULL);
65+
res = run_command_v_opt(args.v, 0);
66+
strvec_clear(&args);
67+
68+
if (res) {
69+
error(_("'sudo apt-get update' failed; is apt-get installed?"));
70+
return 1;
71+
}
72+
73+
printf("\nUpgrading microsoft-git with 'sudo apt-get upgrade microsoft-git'\n\n");
74+
strvec_pushl(&args, "sudo", "apt-get", "upgrade", "microsoft-git", NULL);
75+
res = run_command_v_opt(args.v, 0);
76+
strvec_clear(&args);
77+
78+
return res;
6179
}
6280
#endif
6381

0 commit comments

Comments
 (0)