# How to 'edit' a diff patch properly during ember-cli update?

**URL:** <https://discuss.emberjs.com/t/how-to-edit-a-diff-patch-properly-during-ember-cli-update/6504>\
**Category:** Ember CLI\
**Created:** [October 15, 2014, 1:56pm UTC](https://discuss.emberjs.com/t/how-to-edit-a-diff-patch-properly-during-ember-cli-update/6504 "2014-10-15T13:56:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nightire](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/nightire/32/14788_2.png) [@nightire](https://discuss.emberjs.com/u/nightire)\
**Post date:** [October 15, 2014, 1:56pm UTC](https://discuss.emberjs.com/t/how-to-edit-a-diff-patch-properly-during-ember-cli-update/6504/1 "2014-10-15T13:56:51Z")

</div>

The last step to upgrade an ember-cli app, after you type `ember init`, I found a new option **edit** that allow you to edit a diff patch directly, “Great!” I thought at first…until I encounter an error message again and again, it says:

`Patch was not cleanly applied. Please choose another action.`

Okay, copy that, but how am I suppose to patch it cleanly? For example, I started with a patch file like this:

```diff
Index: /Users/nightire/code/dearann/client/app/app.js
===================================================================
--- /Users/nightire/code/dearann/client/app/app.js
+++ /Users/nightire/code/dearann/client/app/app.js 
@@ -1,17 +1,16 @@
 import Ember from 'ember';
 import Resolver from 'ember/resolver';
 import loadInitializers from 'ember/load-initializers';
+import config from './config/environment';

 Ember.MODEL_FACTORY_INJECTIONS = true;

 var App = Ember.Application.extend({
+ modulePrefix: config.modulePrefix,
+ podModulePrefix: config.podModulePrefix,
+ Resolver: Resolver
- modulePrefix: 'dearann', // TODO: loaded via config
- Resolver: Resolver,
- ready: function () {
- moment.locale('zh-cn');
- }
 });

+loadInitializers(App, config.modulePrefix);
-loadInitializers(App, 'dearann');

 export default App;

```

and change to this (use vim) :

```diff
Index: /Users/nightire/code/dearann/client/app/app.js
===================================================================
--- /Users/nightire/code/dearann/client/app/app.js
+++ /Users/nightire/code/dearann/client/app/app.js 
@@ -1,17 +1,16 @@
import Ember from 'ember';
import Resolver from 'ember/resolver';
import config from './config/environment';
import loadInitializers from 'ember/load-initializers';

Ember.MODEL_FACTORY_INJECTIONS = true;

var App = Ember.Application.extend({
  Resolver: Resolver,
  modulePrefix: config.modulePrefix,
  podModulePrefix: config.podModulePrefix,
  ready: function () {
    moment.locale('zh-cn');
  }
});

loadInitializers(App, config.modulePrefix);

export default App;

```

Save and exit, then I think it should be work enough, but still “was not cleanly” even after I delete the first five lines as well, that drives me crazy!

Is there anyone who can manage this correctly? I would appreciate it someone can show me a screencast or short GIF demonstration, thanks in advance.

---

<div class="post-metadata">

**Author:** ![stevenwu](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@stevenwu](https://discuss.emberjs.com/u/stevenwu)\
**Post date:** [October 17, 2014, 8:22am UTC](https://discuss.emberjs.com/t/how-to-edit-a-diff-patch-properly-during-ember-cli-update/6504/2 "2014-10-17T08:22:53Z")

</div>

I think this is what you want.

```
Index: /Users/nightire/code/dearann/client/app/app.js
===================================================================
--- /Users/nightire/code/dearann/client/app/app.js
+++ /Users/nightire/code/dearann/client/app/app.js 
@@ -1,17 +1,19 @@
 import Ember from 'ember';
 import Resolver from 'ember/resolver';
 import loadInitializers from 'ember/load-initializers';
+import config from './config/environment';

 Ember.MODEL_FACTORY_INJECTIONS = true;

 var App = Ember.Application.extend({
+ modulePrefix: config.modulePrefix,
+ podModulePrefix: config.podModulePrefix,
+ Resolver: Resolver,
- modulePrefix: 'dearann', // TODO: loaded via config
- Resolver: Resolver,
   ready: function () {
     moment.locale('zh-cn');
   }
 });

+loadInitializers(App, config.modulePrefix);
-loadInitializers(App, 'dearann');

 export default App;

```

The header `@@ -1,17 +1,16 @@` is key. This represents `@@ from-range to-range @@`.

If you don’t want a line removed, then replace `-` with a blank space `' ' `. Make sure the indentation lines up. For each substitution, add 1 to the second number in the `to-range`. In this case, I’ve kept the `ready` function, so

`@@ -1,17 +1,16 @@`

becomes

`@@ -1,17 +1,19 @@`.

Note that I also added a comma to the end of `+ Resolver: Resolver`.

If you don’t want to include a `+` line, then just delete the line. Subtract 1 from the second number in the `to-range` for each deleted line.

HT [@joaquin\_win](https://twitter.com/joaquin_win) for [Joaquín Windmüller — Selectively select changes to commit with git (or Imma edit your hunk)](http://joaquin.windmuller.ca/post/selectively-select-changes-to-commit-with-git-or-imma-edit-your-hunk/on:2011-11-16@20:54:30).

---

<div class="post-metadata">

**Author:** ![nightire](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/nightire/32/14788_2.png) [@nightire](https://discuss.emberjs.com/u/nightire)\
**Post date:** [October 17, 2014, 9:19am UTC](https://discuss.emberjs.com/t/how-to-edit-a-diff-patch-properly-during-ember-cli-update/6504/3 "2014-10-17T09:19:02Z")

</div>

Thank you very much, now I understand it at all.
